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
Click For Summary

Discussion Overview

The discussion revolves around a problem in MATLAB where a user is trying to display multiple outputs in a listbox but finds that the current output replaces the previous one. The context involves programming and debugging within MATLAB, specifically related to handling outputs in a graphical user interface (GUI).

Discussion Character

  • Technical explanation, Homework-related

Main Points Raised

  • A user describes their issue with a for loop that processes images and calculates averages, intending to display image names in a listbox when certain conditions are met.
  • The user shares a snippet of their code and notes that the listbox output keeps replacing previous entries instead of accumulating them.
  • Another participant inquires about the programming language being used, confirming it is MATLAB.
  • A subsequent post expresses a desire for further assistance, indicating urgency in resolving the issue.

Areas of Agreement / Disagreement

The discussion does not present any consensus or resolution, as the main issue remains unaddressed and participants have not yet provided solutions or alternative approaches.

Contextual Notes

The user’s code snippet suggests that the method used to update the listbox may not be accumulating strings correctly, but specific assumptions about the intended functionality and the listbox's behavior are not fully explored.

Who May Find This Useful

Individuals working with MATLAB who are dealing with GUI elements, particularly those interested in managing dynamic outputs in listboxes or similar components.

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 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K