How do i save into a picture file a plot used with hold on(i mean:which has several images plot on a 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(figure,'alright.jpg')
end

Respuestas (1)

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

Thank you.
I wish to create a jpg on the final plot of the for loop. You know that the hold on plots on the same figure. Soni need to creat a jpg for the eventual/final plot(the single plot that plots all the iteration with the hold on)
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Entering Commands en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 14 de Mzo. de 2016

Comentada:

el 14 de Mzo. de 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by