How to apply LOOP Function to this simple problem??
1 回表示 (過去 30 日間)
古いコメントを表示
....
....
...
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 件のコメント
採用された回答
Image Analyst
2013 年 3 月 24 日
編集済み: Image Analyst
2013 年 3 月 24 日
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 件のコメント
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!