Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Update static text for Guide Gui from main matlab function

Subject: Update static text for Guide Gui from main matlab function

From: Ioan Alexandru

Date: 13 Mar, 2013 20:40:07

Message: 1 of 3

Dear Community,

I've been going round and round the Matlab documentation and available threads for some time now and I couldn't manage to find a solution to this:
Let's say I have function A.m and GUI.m. A.m has one big function with lots of things in it. GUI.m is the Guide Gui Matlab file which contains all the functions for CreateFcn, Callback, etc. When I run A.m from GUI.m (suppose I call A.m when I press a button from GUI), function A.m obviously will start doing stuff. However, I want to be able to change, for example, the text in a static text box of the GUI.m from within A.m while it is running. Unfortunately, I wasn't able to find a solution to this. Most threads revolve around calling an external function from within , let's say, a callback gui function.
I would really appreciate your support. Thank you very much.

Regards,
Alex

P.S.: is there a way of doing it in a simple was as?:
%line in A.m
GUI(set(handle.statictext,'String','EUREKA'));

I understand that the GUI functions are "nested" so inaccessible to the A.m but I was hopping that there would be a way of calling the handles in something similar to this. The expectation is fairly simple: I want to change the content of a GUI static text box from any external function I wish: even command line.
Thank you

Subject: Update static text for Guide Gui from main matlab function

From: Kristin

Date: 15 Mar, 2013 03:27:08

Message: 2 of 3

"Ioan Alexandru" wrote in message <khqo77$kel$1@newscl01ah.mathworks.com>...
> Dear Community,
>
> I've been going round and round the Matlab documentation and available threads for some time now and I couldn't manage to find a solution to this:
> Let's say I have function A.m and GUI.m. A.m has one big function with lots of things in it. GUI.m is the Guide Gui Matlab file which contains all the functions for CreateFcn, Callback, etc. When I run A.m from GUI.m (suppose I call A.m when I press a button from GUI), function A.m obviously will start doing stuff. However, I want to be able to change, for example, the text in a static text box of the GUI.m from within A.m while it is running. Unfortunately, I wasn't able to find a solution to this. Most threads revolve around calling an external function from within , let's say, a callback gui function.
> I would really appreciate your support. Thank you very much.
>
> Regards,
> Alex
>
> P.S.: is there a way of doing it in a simple was as?:
> %line in A.m
> GUI(set(handle.statictext,'String','EUREKA'));
>
> I understand that the GUI functions are "nested" so inaccessible to the A.m but I was hopping that there would be a way of calling the handles in something similar to this. The expectation is fairly simple: I want to change the content of a GUI static text box from any external function I wish: even command line.
> Thank you

To change the text from within the A.m function, you will need the handle of the text box:
set(handle, 'String', 'I just modified it.');

If you do not have this and need it, then you need to rewrite your program. Sorry to be so blunt...

But, a really crappy way to do this is to get the children of the figure and search for the one you want, perhaps by the properties Tag, Style, String, Position, or UserData. Hopefully it has some property that differs from the other uicontrol objects.

Subject: Update static text for Guide Gui from main matlab function

From: Nasser M. Abbasi

Date: 15 Mar, 2013 04:52:09

Message: 3 of 3

On 3/13/2013 2:40 PM, Ioan Alexandru wrote:


>something similar to this. The expectation is fairly simple: I want to change
>the content of a GUI static text box from any external function I wish: even command line.
> Thank you
>

I do not know about command line. You started talking about GUIDE,
then now started to talk about command line.

In GUIDE, double click on the control you want to change, in
this case it is the static text.

look for the tag field.

put a name there.

in your m file, in the callback, now you can access this
text field using its handle, which is the name you put there in
the tag field in GUIDE.

once you have the handle, you can use the set() command to
change any properties, including the value.

--Nasser

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us