How do I create a loop for a .m file that has multiple functions in it?
Show older comments
I have modified a .m file from https://www.mathworks.com/matlabcentral/fileexchange/25682-color-threshold (It takes an image and allows user to make some modifications to it).
Basically it is an .m file with multiple functions in it. I want to be able to run through multiple pictures contained in a specified folder. From my understanding I can't run a loop for all the functions, so I created a script as the following:
waitfor(msgbox('Choose the directory your pictures are in'))
directory=uigetdir; %Saves all files to this location
cd(directory)
i=1;
listFiles = dir('*.jpg');
for i=1:length(listFiles)
ColorThreshold(listFiles, i, directory)
end
However, it only loops through the first function of "ColorThreshold" (Cropping the image). It isn't until the last image that it actually runs through all the functions? I would like for it to go through all the functions contained in the .m file for every single picture. I am confused as why it only goes through all the functions in the .m file for the last image.
**Edit, it seems that it is running through all the functions in the .m file, but it is not waiting for any user input with the other functions. Is there a way for me to edit the functions so the loop only continues when I press a certain button?
Thanks for any help.
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!