I need to manipulate a static text in MATLAB GUI that needs to increment 1 every time the main program results a TRUE, how do I do this?

1 visualización (últimos 30 días)
I have a program that results into either a TRUE or a FALSE... But in GUI, every time the result is TRUE, I need a static text to keep count and add 1 to itself per result of TRUE. How will I make this work?

Respuestas (1)

Joseph Cheng
Joseph Cheng el 27 de Feb. de 2015
Well what you'd do is set a counter variable that you keep track and increment whenever you get a true statement. then you can use the set() command to set the static text to
set(handles.text1,'String',['number of true: ' num2str(Truecounter)]);
  2 comentarios
Phillip Tiam Watt
Phillip Tiam Watt el 27 de Feb. de 2015
What do you mean by counter variable? such as:
countM = countM + 1
like that?
I'm sort of new to this type of programming so your help is very much appreciated
Joseph Cheng
Joseph Cheng el 27 de Feb. de 2015
yes, in whatever portion you are determining the outcome to be either true or false you'll have to setup a counter. such that in pseudocode:
%X is whatever you're trying to find out if it is true or false
if X>threshold
outcome = true;
numTrue = numTrue + 1;
set text string to new numTrue value;
else
outcome = false;
end
at the start of the gui you'd want to initialize the numTrue counter to 0. if you're using GUIDE, i'd suggest defining the counter in the handle structure as that is passed to each callback

Iniciar sesión para comentar.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by