Friday, 15 April 2011

Displaying multiple plots in Matlab figures -



Displaying multiple plots in Matlab figures -

i want draw 2 figures , save them suva1.fig , suva2.fig respectively. in first figure there 5 identical lines , in sec figure there 4 identical lines. next codes. cant desired plots. please indicate how edit code desired results.

clear clc x1=[1:1:50]; y1=[1:1:50]; x2=[1:2:100]; y2=[1:2:100]; i=1:2 if (i==1) j=1:5 h=figure plot(x1,y1,'o') hold on end saveas(h, 'suva1','fig') end if (i==2) j=1:4 h=figure plot(x2,y2,'o') end saveas(h, 'suva2','fig') end end

from code, doesn't you're trying display multiple plots in single figure. also, i'm not sure why set loop for(j = 1:5)

to plot multiple lines on same plot, utilize hold on command:

h=figure plot(x1, y1, 'o'); hold on; plot(x2, y2, 'k'); hold off;

to utilize subplots:

h = figure; subplot(2,1,1); plot(x1,y1,'o'); hold on; subplot(2,1,2); plot(x2,y2,'k'); hold off;

to save 2 separate plots:

h = figure; plot(x1,y1,'o'); saveas(h, 'suva1','fig'); close(h); h2 = figure; plot(x2,y2,'o'); saveas(h2, 'suva2','fig'); close(h2);

matlab

No comments:

Post a Comment