MATLAB: Plot with For Loop Fixed Variables -
in matlab, have following output of data script:
a1 = [1 2;3 4] a2 = [2 2; 4 5] a3 = [3 5; 7 8]
i need create loop step through each variable , plot. like:
for = 1:3 plot(a(i)) end
so a1 generate plot. a2 generate plot. , a3 generate plot.
thanks
loop using eval
(will emulate variable variable) , figure
(will create figure each a):
a1 = [1 2;3 4]; a2 = [2 2; 4 5]; a3 = [3 5; 7 8]; = 1:3 figure(i); eval(['plot(a' num2str(i) ');']) end
if have many might want save plots automatically, inserting following line right after eval line in loop:
print('-dpng','-r100',['a' int2str(i)])
Comments
Post a Comment