how to change static text in MATLAB GUI?

조회 수: 85 (최근 30일)
Kobi
Kobi 2015년 7월 7일
댓글: Rik 2020년 2월 8일
how to change static text in MATLAB GUI?

채택된 답변

Image Analyst
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
Sadat Azad 2020년 2월 8일
Thanks, I was planning to save the string in a text file, This seems like a better idea.
Rik
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
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?

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by