Why Does My Listbox Output Keep Replacing the Previous One in Matlab?

  • Context: MATLAB 
  • Thread starter Thread starter jaclyn89
  • Start date Start date
  • Tags Tags
    Output
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 3K views
jaclyn89
Messages
5
Reaction score
0
hi, i am facing some problem when i want to display several output in a listbox.

i have 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. when i have 5 images' average<=10, then i should display 5 images name in the list box. but now my problem is, the current output will keep replace the previous output.

anyone can help me? 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 )


newText=sprintf('the percentage of diffrence for <<%s>> is %0.0f \n ',filename,aveg(k));
set(handles.listbox1,'String',newText);

else

set(handles.listbox1,'String','');
end
end
 
Physics news on Phys.org
yes, i am using matlab...