Making a matlab GUI and displaying a value from a iterative loop (on a seperate m file) on a staticText

4 visualizaciones (últimos 30 días)
He everyone,
I have a large for-loop in a script (lets call it Part1.m), from which I would like to take a variable (var) and disply it on a gui static-text box, with the gui updating the value every loop. Suppose the Gui is 'Part2.fig' and the associated script is 'Part2.m', how would i accomplish this.
as an example, suppose the loop in Part1.m is:
for n=1:100
var=n*10;
end
at every iteration i woould like the value of var to be displayed on the Gui Part2.fig. How do I do this. The only answer i found as of now is https://de.mathworks.com/matlabcentral/answers/110164-how-to-get-dynamic-changing-text-or-data-in-matlab-gui-in-a-panel-window. however, I dont seem to be able to find a set function when i create the staticText gui.
Thanks in advance

Respuesta aceptada

Walter Roberson
Walter Roberson el 7 de Nov. de 2016
handle_to_part2 = part2();
handles_part2 = guidata(handle_to_part2);
for n=1:100
var=n*10;
set(handles_part2.text1, 'String', num2str(var) );
drawnow;
end
Change the "text1" to the name of the tag inside part2.fig
The first line,
handle_to_part2 = part2();
is executing part2() so that part2 will tell you its figure number. The handles structure for a GUIDE-created GUI are attached to the particular figure, not to some kind of "project", so you need to find out which figure it is to retrieve the handles structure
  3 comentarios
Walter Roberson
Walter Roberson el 19 de Oct. de 2018
Sorry, I am not familiar with how app designer stores variables. I believe the design philosophy is not the same.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by