How do i save into a picture file a plot used with hold on(i mean:which has several images plot on a figure)?
Mostrar comentarios más antiguos
for uuu=2000:50:4900;
name_file=strcat('res_to_U_', num2str(uuu),'.mat')
BB = load(name_file);
plot(uuu,BB.Resp(:,3))
hold on
saveas(figure,'alright.jpg')
end
Respuestas (1)
Geoff Hayes
el 14 de Mzo. de 2016
Ibukunolu - according to saveas, you need to pass in the handle to the figure that you are drawing to. For example,
hFig = figure;
for uuu=2000:50:4900;
name_file=strcat('res_to_U_', num2str(uuu),'.mat')
BB = load(name_file);
plot(uuu,BB.Resp(:,3))
hold on
saveas(hFig,'alright.jpg')
end
Of course, on every iteration of the for loop, you will overwrite the alright.jpg. Is this the intent, or do you wish to create a new image/jpg on each iteration of the loop?
2 comentarios
Ibukunolu Oladunjoye
el 14 de Mzo. de 2016
Geoff Hayes
el 14 de Mzo. de 2016
Since you only want to create a jpg of the final plot, then I would move the saveas to outide of the loop
hFig = figure;
for uuu=2000:50:4900;
name_file=strcat('res_to_U_', num2str(uuu),'.mat')
BB = load(name_file);
plot(uuu,BB.Resp(:,3))
hold on
end
saveas(hFig,'alright.jpg')
Please try the above. If it doesn't work, then describe the behaviour or errors that you are observing.
Categorías
Más información sobre Entering Commands en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!