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

4 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2016-11-7
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 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by