Reputation: 119
Say i have a for-loop.
count=1;
for t=1:20
while(true)
figure();
(do sth...)
view([-90 -90])
pause(0.01)
M(count)=getframe;
count=count+1;
end
movie2avi(M, 're.avi');
end
Inside the for-loop there is a while loop where i am making my movie. But in each iteration of for loop one movie is made. I want to store each movie with name as re1, re2,...re20,etc. How to do modify the command movie2avi(M, 're.avi');
to do it?
Upvotes: 0
Views: 31
Reputation: 8401
Convert the index t
to a string using num2str
and concatenate:
movie2avi(M, ['re',num2str(t),'.avi']);
This will generate re1.avi
,re2.avi
,...,re20.avi
.
For better sorting of the files, you may want to add a leading 0
to the filenames as well:
movie2avi(M, ['re',num2str(t,'%02G'),'.avi']);
This will generate re01.avi
,re02.avi
,...,re20.avi
. The extra argument '%02G'
is a formatspec that creates an integer-looking string of at least length 2 with zeros padding numbers of length 1.
Upvotes: 1