matlab - Plotting and saving a plot in a loop after the entire loop is done -
i need keep updating plot within loop because doing linear regression each segment in space. can fine , display correct plot. don't seem able save final plot file. code looks like:
for = 1:slabs %.....some looped results here, shortened brevity..... p = polyfit(collectcoord, collecttemp, 1); t2 = floor(min(collectcoord)) : 0.1 : ceil(max(collectcoord)); y2 = polyval(p,t2); h = plot(collectcoord, collecttemp, 'o', t2, y2); xlabel('x-coordinate') ylabel('temperature') axis([-8 8 50 800]) hold on end filename = [folder 'plot' num2str(stepcount) '.jpg']; saveas(h, filename); what doing wrong here, or there better way of saving plot?
you're calling saveas() on handle line plotted. need supply figure handle:
f = figure(); stuff; saveas(f, 'file.jpg'); or saveas(gcf(), 'file.jpg');
Comments
Post a Comment