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!