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

  • Thread starter Thread starter jaclyn89
  • Start date Start date
  • Tags Tags
    Output
AI Thread Summary
The discussion centers on a problem with displaying multiple outputs in a listbox using MATLAB. The user is attempting to load images from a specified directory and calculate an average value for each image. If the average is less than or equal to 10, the image's name should be displayed in the listbox. However, the current implementation only shows the most recent image name, replacing previous entries instead of accumulating them. The user seeks assistance to modify the code so that it retains all relevant image names in the listbox. The code snippet provided shows the image loading process and the conditional logic for displaying the names, but it lacks the functionality to append new entries to the listbox.
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
well first question is what programming language are you using? is this matlab?
 
yes, i am using matlab...
 
anyone please...
 

Similar threads

Replies
3
Views
4K
Back
Top