MATLAB Answers

Kobi
0

how to change static text in MATLAB GUI?

Asked by Kobi
on 7 Jul 2015
Latest activity Commented on by Poorna Hewapathirana on 19 Mar 2019
how to change static text in MATLAB GUI?

  0 Comments

Sign in to comment.

2 Answers

Answer by Image Analyst
on 7 Jul 2015

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.

  3 Comments

@image analyst: your code is more simple. thanks sir !
It's even simpler if you use OOP syntax:
handles.text1.String = myString; % Do it like this instead of using set()
Thans a lot. Thats very helpful

Sign in to comment.


Answer by Sid
on 7 Jul 2015

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 Comments

Sign in to comment.