Matlab subplot画图。

15 views (last 30 days)
mjjkcdr
mjjkcdr on 22 May 2023
Answered: tqqxaxrw on 22 May 2023
版本:Matlab R2017_b
代码核心部分如下:
mx = min(x);
Mx = max(x);
s = size(imf);
k = s(1);
M = max(max(abs(imf(1:k-1,:))));
subplot(k+1,1,1)
plot(t,x)
axis([t(1) t(s(2)) mx Mx])
set(gca,'YTick',[])
set(gca,'XTick',[])
ylabel(['signal'])
for j = 1:k-1
subplot(k+1,1,j+1)
plot(t,imf(j,:))
axis([t(1) t(s(2)) -M M])
set(gca,'YTick',[])
set(gca,'XTick',[])
ylabel(['imf',int2str(j)])
end
subplot(k+1,1,1)
title('Empirical Mode Decomposition')
mr = min(imf(k,:));
Mr = max(imf(k,:));
subplot(k+1,1,k+1)
plot(t,imf(k,:),'r')
axis([t(1) t(s(2)) mr Mr])
set(gca,'YTick',[])
set(gca,'XTick',[])
ylabel('res.')
以上代码画出来的是图一。
请问怎么修改参数画出类似图二的效果。要求是Signal在第1行,下面5行2列画出imf 1~9和res.。

Accepted Answer

tqqxaxrw
tqqxaxrw on 22 May 2023
仅供参考,试试
mx = min(x);
Mx = max(x);
s = size(imf);
k = s(1);
M = max(max(abs(imf(1:k-1,:))));
subplot(k/2+1,2,[1,2])
plot(t,x)
axis([t(1) t(s(2)) mx Mx])
set(gca,'YTick',[])
set(gca,'XTick',[])
ylabel(['signal'])
for j = 1:k-1
        subplot(k/2+1,2,j+2)
        plot(t,imf(j,:))
        axis([t(1) t(s(2)) -M M])
        set(gca,'YTick',[])
        set(gca,'XTick',[])
        ylabel(['imf',int2str(j)])
end
subplot(k+1,1,1)
title('Empirical Mode Decomposition')
mr = min(imf(k,:));
Mr = max(imf(k,:));
subplot(k+1,1,k+1)
plot(t,imf(k,:),'r')
axis([t(1) t(s(2)) mr Mr])
set(gca,'YTick',[])
set(gca,'XTick',[])
ylabel('res.')

More Answers (0)

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!