필터 지우기
필터 지우기

Saving Lots of Plots as Variable Changes in Time

조회 수: 3 (최근 30일)
K
K 2013년 6월 18일
Alright, this may be a simple question, but I am still learning. I am trying to generate a file with a variable number of plots, perhaps 10 per page. I have a variable, a, that I would like to change, and every time it changes I want a new plot. I was planning on doing this in a for loop like so:
for a=400:5:500
b(a)=equation
function
function
function
plot(output,'r');
axis([0 max(output)+10 -20 400])
hold on
plot(my data,'k'); %as background to see changes
hold off
end
Ideally, I would have 50 plots saved somewhere with all the different values of a worked through the functions. As it is, I get one plot with the final value of a input, which I expected due to the way I currently have it written.
I am also thinking it would be fun to make a movie showing the change in 'a' as it changes for each frame.
Any advice?

채택된 답변

Iain
Iain 2013년 6월 18일
for a = 400:5:500
% do stuff to get your results.
figure(n)
plot(output,'r');
axis([0 max(output)+10 -20 400])
hold on
plot(my data,'k'); %as background to see changes
hold off
saveas(n,[folder '\' filename num2str(a) '.png'])
% eg saveas(n,['D:\My random storage location\' 'images' num2str(a) '.png'])
end
That'll save it all to file. (n can be any positive integer)
Look up the help documentation for "avifile" to get some of the code you need for creating avi files.
  댓글 수: 2
Tom
Tom 2013년 6월 18일
A lesson I learned from leaving a similar sort of program running overnight is to get rid of the figure once it's saved...
close(n)
Iain
Iain 2013년 6월 18일
And depending on what else you're doing/have done its best to make n an unusual number, like 171

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

K
K 2013년 6월 18일
Thank you! That works great

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by