MATLAB: How to run m-files automatically

loop over file names

Hi,
I have collection of images to analyze using matlab. I made m-file code to analyze one image at a time, but it takes considerable time as there are hundreds of images to run.
Is there anyway to call the files in the folder and run one at a time automatically, without me designating the file name one by one?
Thank you very much for help.

Best Answer

D = dir('*.jpg');
for ii = 1:length(D)
% Put your processing code here. Call image names as below...
fprintf('Processing image named %s\n',D(ii).name);
end
Related Question