f



Passing data between Simulink and MATLAB GUI

I've designed a GUI with GUIDE, I succedeed to obtain Simulink signals' data when the simulation is stopped but I can't update my GUI in real-time during the simulation. For example I want to show the time on a text label, in real-time or every N seconds. In the second case I've created a timer which calls a callback_timer in which I update my text label... well...I supposed it was simple but I was wrong. 
For debugging purpose I inspected 'gbco', expecting to get the handle of the GUI object, in order to update my text labels. 

I declare my timer:
t = timer('StartDelay',1,'TimerFcn',{@callback_timer}, 'Period', 1, 'ExecutionMode', 'fixedRate');
t.StartFcn = {@callback_timer};
start(t)

And then in the first callback call I obtain the following object handler with gcbo: 
4.1160e+003
but after that I always get a null object handler: []
I studied MATLAB docs and the examples I found on Internet but I don't know where the error is.

Thank you in advance, 

Matteo De Felice
ENEA - Rome, Italy
-1
3/9/2009 10:59:02 AM
comp.soft-sys.matlab 211266 articles. 17 followers. lunamoonmoon (258) is leader. Post Follow

2 Replies
419 Views

Similar Articles

[PageSpeed] 44

"Matteo " <matteo.defelice@enea.it> wrote in message <gp2spm$jj$1@fred.mathworks.com>...
> I've designed a GUI with GUIDE, I succedeed to obtain Simulink signals' data when the simulation is stopped but I can't update my GUI in real-time during the simulation. For example I want to show the time on a text label, in real-time or every N seconds. In the second case I've created a timer which calls a callback_timer in which I update my text label... well...I supposed it was simple but I was wrong. 
> For debugging purpose I inspected 'gbco', expecting to get the handle of the GUI object, in order to update my text labels. 
> 
> I declare my timer:
> t = timer('StartDelay',1,'TimerFcn',{@callback_timer}, 'Period', 1, 'ExecutionMode', 'fixedRate');
> t.StartFcn = {@callback_timer};
> start(t)
> 
> And then in the first callback call I obtain the following object handler with gcbo: 
> 4.1160e+003
> but after that I always get a null object handler: []
> I studied MATLAB docs and the examples I found on Internet but I don't know where the error is.
> 
> Thank you in advance, 
> 
> Matteo De Felice
> ENEA - Rome, Italy

The easiest way to have Simulink talk to a MATLAB GUI is to make the GUI (part of) an S-function within the model.
In this way signal values and the simulation time are passed to your UI automatically by Simulink.
There are some ways to get a non S-Function UI to display Simulink signals but they are quite messy and there are no examples of doing it (that I'm aware of).

You don't say how you start the execution of your (above) timer code.
Is it part of a callback from pressing a button?
If so, then my suspicion is that the handle you get on first execution is the handle to the button that you've just pressed, then on subsequent calls, because the event/callback isn't fired from manually pressing a uicontrol gcbo should be empty.

Phil.
0
3/10/2009 3:20:02 AM
> The easiest way to have Simulink talk to a MATLAB GUI is to make the GUI (part of) an S-function within the model.
> In this way signal values and the simulation time are passed to your UI automatically by Simulink.
> There are some ways to get a non S-Function UI to display Simulink signals but they are quite messy and there are no examples of doing it (that I'm aware of).
> 
> You don't say how you start the execution of your (above) timer code.
> Is it part of a callback from pressing a button?
> If so, then my suspicion is that the handle you get on first execution is the handle to the button that you've just pressed, then on subsequent calls, because the event/callback isn't fired from manually pressing a uicontrol gcbo should be empty.


Thank you for your reply. Yes, you're right, the timer starts with a button - so probably the handle I get is the one of the pressed button. Well, I'll try with something different,
thank you again,

Matteo De Felice
0
3/10/2009 8:00:03 AM
Reply: