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
0 个评论
采纳的回答
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 个评论
Walter Roberson
2018-10-19
Sorry, I am not familiar with how app designer stores variables. I believe the design philosophy is not the same.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!