How to get dynamic/changing text or data in MATLAB GUI in a panel window??
조회 수: 27 (최근 30일)
이전 댓글 표시
How can I manipulate text/numerical data from my matlab code onto my GUI in a panel box?
I want to print values from data in my script and have them on my GUI. I'm aware of static text and the edit text box, but I want the text which is displayed to come from values in my script. Example from data in my script:
Value = 50;
Then I want matlab to print Value to a panel on my GUI where a static text box says -
My number is:
Value
i.e My number is:
50
댓글 수: 0
채택된 답변
Image Analyst
2013년 12월 19일
Call set():
set(handles.staticText1, 'String', num2str(value));
You might even be able to get away with not using num2str() - I'd have to try it to see though. Obviously replace staticText1 with whatever name you gave to the "tag" property of the edit text or static text control that you want to set the value of. So bottom line, whenever you want to change or update the value of the text control, call set().
However, one watch out : If you're in an intensive loop it might not have a chance to update the GUI before it goes racing along with your loop. It might even finish your loop without ever updating the text. If that happens, put a " drawnow " command right after the "set" command.
댓글 수: 4
Craig Kavan Pinto
2016년 11월 7일
When you say call 'set', where exactly do you call it? I have a similar problem, where my script (lets say Part1.m) has a value that i want to send to a gui (lets say Part2.gui and Part2.fig). However, I am not able to find the set function, or most probably i am calling it at the wrong place. Thanks in advance for the help.
Walter Roberson
2016년 11월 7일
추가 답변 (1개)
Walter Roberson
2013년 12월 19일
A = uicontrol('Style','text','max',2, 'Units', 'norm', 'Position',[0 0 1 1]);
S = {'My value is:'};
for K = 1 : 10
S{2} = sprintf('%d', K);
set(A, 'String', S);
pause(1/2);
end
댓글 수: 3
Walter Roberson
2013년 12월 19일
Your GUI cannot pull the values calculated from your script. Your script will have to push values to the GUI.
To get text onto the GUI, you will need to use text(), which works in a graphics axis, or you will need to set() a property of a uicontrol() that you already created and put into position. Yes, you will need handles to do this. You can add a Tag property to the output component to allow you to find the component without knowing its handle ahead of time.
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!