How to apply LOOP Function to this simple problem??
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
....
....
...
figure(1)
plot(t(1:32768),x1,'r','linewidth',1)
title('Waveform','Fontname','Times new roman','FontSize',35,'fontweight','b')
set(gca, 'FontName','Times New Roman', 'FontSize',35,'fontweight','b')
xlabel('Time (s)','Fontname','Times new roman','FontSize',35,'fontweight','b')
ylabel('Ampiltude (mils)','Fontname','Times new roman','FontSize',35,'fontweight','b')
I would like to generate multiple graphs indvidually (say 10) between t and x1,x2,x3,x4.....x10 such that when i run the command, 10 separate graph files open at once with name such as figure1, figure2, figure3,.....figure10. Kindly tell me how to apply loop function here.
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 24 Mär. 2013
Bearbeitet: Image Analyst
am 24 Mär. 2013
Assuming you have a known, fixed number of xn variables, and it doesn't change with each run of the program, you can just simply wrap it in a loop:
for k = 1 : 10
if k == 1
x = x1;
elseif k == 2
x = x2;
elseif k == 3
x = x3;
elseif k == 4
x = x4;
elseif k == 5
x = x5;
elseif k == 6
x = x6;
elseif k == 7
x = x7;
elseif k == 8
x = x8;
elseif k == 9
x = x9;
elseif k == 10
x = x10;
end
figure;
plot(t(1:32768),x,'r','linewidth',1)
title('Waveform','Fontname','Times new roman','FontSize',35,'fontweight','b')
set(gca, 'FontName','Times New Roman', 'FontSize',35,'fontweight','b')
xlabel('Time (s)','Fontname','Times new roman','FontSize',35,'fontweight','b')
ylabel('Ampiltude (mils)','Fontname','Times new roman','FontSize',35,'fontweight','b')
end
If you don't have 10 x variables with each run, then you must be doing what the FAQ explicitly recommends that you don't do.
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!