Using a for loop to open files in Matlab?
I’m looking to write an application that sequentially goes into business a compilation of images, each one of these called ‘image001.png’ about ‘image010.png’.It would take for a long time to create the computer code to wide open each singularly, so I’m looking to write a for picture to wide open each as well as perform many operations in it.Even so, I can’t determine how.Right now I have been previously trying to accomplish this:
>> stringarray = ‘image001.png’, ‘image002.png’, ‘image003.png’;
>> the = imread(‘stringarray(1)’)
but I simply get one saying ”stringarray(1)’ just isn’t a file”.Can we really make your for trap which goes through each picture file and also do I must do this one by one
Any help will be appreciated.
There are a few complications here.
(1) You’ve put quotes round the stringarray around imread, so Matlab is interpreting skin anti wrinkle cream between the particular quotes like a literal string – i.e., it’s searching for a record called stringarray(1).For obtaining to rates inside imread should you be using a new variable for your filename.
(2) Should you put this stringarray together of that ranking, it winds up just staying one extended string that appears like this:
image001.pngimage002.pngimage003.png
You can use a mobile phone array on the other hand, like
stringarray = ‘image001.png’, ‘image002.png’, ‘image003.png’;
the = imread(stringarray1);
Observe the curly braces…
(3) Suggestions perhaps a cleaner approach to do what you long for.
intended for i = 1:10
filename = sprintf(‘image%.A model in 3d.png’, i);
img = imread(filename);
physique;
imshow(img);
conclusion.
Leave a Reply
You must be logged in to post a comment.