MATLAB: Plotting subplot with two concurrent plots

figureMATLABplotsubplot

I have two different graphs, which I would like to plot in a 2×5 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

Best Answer

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