Plotting subplot with two concurrent plots

1 回表示 (過去 30 日間)
Nnamdi Ohaka-Akpalaba
Nnamdi Ohaka-Akpalaba 2019 年 3 月 18 日
編集済み: Nnamdi Ohaka-Akpalaba 2019 年 3 月 18 日
I have two different graphs, which I would like to plot in a 2x5 subplot array.
I want the first 5 plots to be for graph1, and the bottom 5 plots to be for graph2, but this needs to all be in the same figure.
figure;
for k = 1:5
subplot(1,5,k);
[val,loca]=(max(abs(squeeze(S(1,k,:,:)))));
plot(T,squeeze(abs(S(1,k,92,:))),T,squeeze(abs(S(1,k,52,:)))); % graph1
legend('f1','f2')
title('Amplitude of f verses time')
ylabel('amplitude A.U')
xlabel('time (ns)')
end
figure;
for k = 1:5
subplot(1,5,k);
plot(T,F(loca),'m'); % graph2
title('Amplitude of f verses time')
ylabel('Frequency (Hz)')
xlabel('time (ns)')
legend('found F')
end
I need help with how to code so its all in one figure

採用された回答

Matt J
Matt J 2019 年 3 月 18 日
編集済み: Matt J 2019 年 3 月 18 日
figure;
for k = 1:5
subplot(2,5,k);
[val,loca]=(max(abs(squeeze(S(1,k,:,:)))));
plot(T,squeeze(abs(S(1,k,92,:))),T,squeeze(abs(S(1,k,52,:)))); % graph1
legend('f1','f2')
title('Amplitude of f verses time')
ylabel('amplitude A.U')
xlabel('time (ns)')
end
for k = 1:5
subplot(2,5,k);
plot(T,F(loca),'m'); % graph2
title('Amplitude of f verses time')
ylabel('Frequency (Hz)')
xlabel('time (ns)')
legend('found F')
end
  1 件のコメント
Nnamdi Ohaka-Akpalaba
Nnamdi Ohaka-Akpalaba 2019 年 3 月 18 日
編集済み: Nnamdi Ohaka-Akpalaba 2019 年 3 月 18 日
Thanks, that was nearly perfect
figure;
for k = 1:5
subplot(2,5,k);
[val,loca]=(max(abs(squeeze(S(1,k,:,:)))));
plot(T,squeeze(abs(S(1,k,92,:))),T,squeeze(abs(S(1,k,52,:)))); % graph1
legend('f1','f2')
title('Amplitude of f verses time')
ylabel('amplitude A.U')
xlabel('time (ns)')
end
for k = 6:10
subplot(2,5,k);
plot(T,F(loca),'m'); % graph2
title('Amplitude of f verses time')
ylabel('Frequency (Hz)')
xlabel('time (ns)')
legend('found F')
end
I just had to change the secong k loop to k = 6:10
This stopped the plots from overlapping

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by