- #1
jaclyn89
- 5
- 0
hi, i am facing some problem in my for loop or ifesle statement in matlab.
i used a for loop to load the images from a folder, after the images loaded, it will gone through some calculation to get the average. if the images average <=10, then i want to display the images name in a listbox. let say i have 10 images in my folder, and average for images' 2,4 and 6 is <=10, the images will still go through else statement. if the average of last image is <=10, it just will stop in if statement and won't go through else statement. anyone know what is the problem?
here is some part of my code:
sdirectory = 'D:\recognition system\database'; %specific the file directory
filess = dir([sdirectory '/*.png']);
for k = 1:length(filess)
filename = [sdirectory '\' filess(k).name];
I = imread(filename);
...
aveg(k)=abs((standev/mean1)*100);
if( aveg(k)<= 10 )
lo{k}=sprintf('%% of diffrence for <<%s>> is %G %%\n\n ',filename,aveg(k));
set(handles.listbox1,'String',lo);
else
set(handles.listbox1,'String','');
end
end
i used a for loop to load the images from a folder, after the images loaded, it will gone through some calculation to get the average. if the images average <=10, then i want to display the images name in a listbox. let say i have 10 images in my folder, and average for images' 2,4 and 6 is <=10, the images will still go through else statement. if the average of last image is <=10, it just will stop in if statement and won't go through else statement. anyone know what is the problem?
here is some part of my code:
sdirectory = 'D:\recognition system\database'; %specific the file directory
filess = dir([sdirectory '/*.png']);
for k = 1:length(filess)
filename = [sdirectory '\' filess(k).name];
I = imread(filename);
...
aveg(k)=abs((standev/mean1)*100);
if( aveg(k)<= 10 )
lo{k}=sprintf('%% of diffrence for <<%s>> is %G %%\n\n ',filename,aveg(k));
set(handles.listbox1,'String',lo);
else
set(handles.listbox1,'String','');
end
end