Trying to change name of image file in for loop - use %s?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Chelsea
am 30 Dez. 2014
Beantwortet: Image Analyst
am 30 Dez. 2014
Hi,
I'm trying to create a for loop, where I gather screen shots and save them (trial 1, trial 2..., etc.). I tried to use the following:
imwrite(imageArray, '%s.jpg',trial)
to create different names for each image, as the loop continues. However, this didn't work. Is there any other way to do this, other than "if trial 1....else if trial 2, etc.?"
I am using PTB, if that's useful.
Thank you!
0 Kommentare
Akzeptierte Antwort
Sean de Wolski
am 30 Dez. 2014
Use the filename as the following
for ii = 1:10
filename = ['trial' num2str(ii) '.jpg']
imwrite(I,filename)
end
It looks like what you were trying to do was use sprintf inside of imwrite. This would work too, but it a little more power than you need:
filename = sprintf('trial%i.jpg',ii)
Weitere Antworten (1)
Image Analyst
am 30 Dez. 2014
Read this part of the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F Then read the rest of it too, because there is lots of good stuff in there.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Image display and manipulation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!