Problem in Using imwrite() Function
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
abhimanyu dubey
am 27 Jul. 2020
Kommentiert: abhimanyu dubey
am 27 Jul. 2020
for i = 1 : 60000
name1 = [ 'something' , num2str(i) , '.tif' ] ;
pj = importdata(name1) ;
% do some processing on pj and then save it to new_fig
new_fig = pj ;
% Write Image Data to a File:
name2 = ['Output_File_' , num2str(i) , '.tif'] ; %%
imwrite(new_fig , name2) ;
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/337672/image.png)
Now the issue is that I want my file names like,
- 'Outfile_File_00001'
- 'Outfile_File_00010'
- 'Outfile_File_00100'
- 'Outfile_File_01000'
you get the idea.
This is required because for subsequent processing. So can anyone suggest me how to go about it. Please remember here, that the overall code is computationally intensive. So I don't want to use any if statments inside the loop. Can we solve this without making use of any if statments.
Thanks :)
2 Kommentare
Image Analyst
am 27 Jul. 2020
So you want the suffix to have all zeros except for a 1 in a certain location? But you have 60 thousand - you can't have a filename 60,000 characters long.
Akzeptierte Antwort
Image Analyst
am 27 Jul. 2020
Bearbeitet: Image Analyst
am 27 Jul. 2020
What I'd do is
name2 = sprintf('Output_File_%6.6d.tif', i);
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!