how to change static text in MATLAB GUI?
56 次查看(过去 30 天)
显示 更早的评论
how to change static text in MATLAB GUI?
0 个评论
采纳的回答
Image Analyst
2015-7-7
First make up your string. Then set the 'String' property of the static text control to that string with the set() command. If it's in an intensive loop, you might have to use drawnow to get it to update immediately.
myString = sprintf('Hello world!\nThe value is %d', someVariable);
set(handles.text1, 'String', myString);
drawnow; % Needed only if this is in a fast loop.
7 个评论
Sadat Azad
2020-2-8
Thanks, I was planning to save the string in a text file, This seems like a better idea.
Rik
2020-2-8
If you want to bind the defaults to your copy of Matlab instead of the current folder, you can use setpref and getpref.
更多回答(1 个)
Sid
2015-7-7
A very basic example:
f = figure;
t = uicontrol(f,'Style','text',...
'String','Select a data set.',...
'Position',[30 50 130 30]);
t.String = 'hello World';
This changes the static text from 'Select a data set.' to 'hello World'
Basically, all you are doing is changing the string property in an object that is of style text .
Does that help?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!