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!