Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

communication between simulink and matlab gui

831 views
Skip to first unread message

Andrea Monastero

unread,
Apr 30, 2008, 6:20:03 AM4/30/08
to
Hi.
I've got a matlab GUI. I want to read outputs of some
simulink blocks from the GUI program and update in real-time
some values of text boxes of the GUI. How can I do?

Thanks.

Ashwini Deshpande

unread,
May 1, 2008, 12:49:03 AM5/1/08
to
"Andrea Monastero" <andrea.m...@gmail.com> wrote in
message <fv9h4j$t6d$1...@fred.mathworks.com>...

Hai,

You can write the Simulink Block output values into a .mat
file using 'To File' block and read the same file from the
matlab GUI.

or else similarly you can also make use of 'To Workspace'
block and then read the workspace parameters from the matlab
GUI.

Regards,
Ashwini

Andrea Monastero

unread,
May 1, 2008, 6:38:04 AM5/1/08
to
Yes I know, but in this way, if I run the simulation from
the GUI with the command "sim(...)", I've got to wait the
end of the simulation before execute the instruction which
reads the file. I need a real time response...

"Ashwini Deshpande" <vd.as...@mathworks.com> wrote in
message <fvbi3v$624$1...@fred.mathworks.com>...

...

> You can write the Simulink Block output values into a .mat
> file using 'To File' block and read the same file from the
> matlab GUI.

...

Ralph Schleicher

unread,
May 1, 2008, 12:41:37 PM5/1/08
to
"Andrea Monastero" <andrea.m...@gmail.com> writes:

> Yes I know, but in this way, if I run the simulation from
> the GUI with the command "sim(...)", I've got to wait the
> end of the simulation before execute the instruction which
> reads the file. I need a real time response...

Use set_param(bdroot, 'SimulationCommand', 'Start') to run
the simulation asynchronously.

--
Ralph Schleicher, Freelance Engineer http://ralph-schleicher.de

Development * Consulting * Training
Mathematical Modeling and Simulation
Software Tools

elizabeth weitzel

unread,
May 9, 2008, 6:57:03 PM5/9/08
to
Is there a way to plot in a GUI window, realtime, the
values that are being generated by a simulink model? Like
having a scope but within a GUI screen?

-Beth W.

Ralph Schleicher <r...@ralph-schleicher.de> wrote in message
<878wyuv...@echo.mueller-schleicher.i>...

Ralph Schleicher

unread,
May 10, 2008, 4:05:14 AM5/10/08
to
"elizabeth weitzel" <elizabet...@baesystems.com> writes:

> Is there a way to plot in a GUI window, realtime, the
> values that are being generated by a simulink model? Like
> having a scope but within a GUI screen?

Yes of course. Add a call-back function to your GUI returning
the handles of the UI objects. Write an M-file S-function with
the Simulink signals as input. Query and cache the UI object
handles in the StartFcn, then update the UI objects in the
mdlUpdate procedure. Done that, works like a charm.

elizabeth weitzel

unread,
May 13, 2008, 4:53:49 PM5/13/08
to
Thank you very much Ralph. It worked beautifully.

Irfan

unread,
Jun 11, 2008, 8:56:02 AM6/11/08
to
"elizabeth weitzel" <elizabet...@baesystems.com>
wrote in message <g0cv4t$g79$1...@fred.mathworks.com>...

> Thank you very much Ralph. It worked beautifully.

Hello Elizabeth

Could you be kind to post an example for plotting realtime
graphs in GUI

IrFaN

Martin Burger

unread,
Jul 11, 2008, 9:04:04 AM7/11/08
to
"Irfan " <irfa...@gmail.com> wrote in message
<g2oi12$m4u$1...@fred.mathworks.com>...


Dear Ralph, Dear Elizabeth,

could you exemplify that problem ...

"Add a call-back function to your GUI returning
the handles of the UI objects. Write an M-file S-function with
the Simulink signals as input. Query and cache the UI object
handles in the StartFcn, then update the UI objects in the
mdlUpdate procedure. "

or provide mor detail

Thanks in advance


Martin

cheah

unread,
Feb 22, 2009, 10:16:01 AM2/22/09
to
"elizabeth weitzel" <elizabet...@baesystems.com> wrote in message <g0cv4t$g79$1...@fred.mathworks.com>...
> Thank you very much Ralph. It worked beautifully.

hey..Regarding the that u wanted take real time data from simulink to GUI..I am currently doing something related to this..but i dun have any idea..
can u give some example of code?

Ralph Schleicher

unread,
Feb 23, 2009, 2:06:26 PM2/23/09
to
"cheah " <kawa...@gmail.com> writes:

> hey..Regarding the that u wanted take real time data from simulink to
> GUI..I am currently doing something related to this..but i dun have
> any idea.. can u give some example of code?

See <http://ralph-schleicher.de/pub/slui/slui-2008-08-30.zip>, for
a complete example.

--
Ralph Schleicher <http://ralph-schleicher.de>

Saidul Hasnan

unread,
May 27, 2009, 5:07:01 PM5/27/09
to
Hi Ralph,

The link doesn't seem to work for me. Could you please re-upload it again?

Regards,
Saidul

Ralph Schleicher <r...@mueller-schleicher.de> wrote in message <871vtpo...@echo.mueller-schleicher.i>...

Phil Goddard

unread,
May 28, 2009, 8:22:02 PM5/28/09
to

Another approach, available in more recent versions of Simulink, is to add listeners on blocks using the function add_exec_event_listener.
(I'm not sure when that function was introduced but it exists in R2008b.)

I have uploaded an example UI/model using this approach to the file exchange:
http://www.mathworks.com/matlabcentral/fileexchange/24294

Phil.

zanna z

unread,
Jul 30, 2010, 6:49:04 AM7/30/10
to
"elizabeth weitzel" <elizabet...@baesystems.com> wrote in message <g0cv4t$g79$1...@fred.mathworks.com>...
> Thank you very much Ralph. It worked beautifully.

could u post an example of this metod? (use s function insted event listener)

trega trega

unread,
Aug 16, 2011, 8:01:16 AM8/16/11
to
"Phil Goddard" <philgodd...@telus.net> wrote in message <gvn9r9$dp0$1...@fred.mathworks.com>...


Hello,
I followed your example and it works very nice, thank you for that. However now I need to access both signals from XYGraph block? Could you tell me how to do that? I changed

sTime = block.CurrentTime;
into:
sTime=block.InputPort(2).Data;
In localEventListener function, but now both variables: sTime and data have the same values. What am I doing wrong?

Arun Badigannavar

unread,
Jan 13, 2012, 1:02:07 AM1/13/12
to
"Andrea Monastero" wrote in message <fv9h4j$t6d$1...@fred.mathworks.com>...
Hi,
I wants to know
How to take a two dimensional signal from MATLAB workspace to the simulink(other waqy thar 'from workspace')

saptesh pandit

unread,
Aug 6, 2016, 2:17:10 AM8/6/16
to
"Andrea Monastero" wrote in message <fv9h4j$t6d$1...@fred.mathworks.com>...
0 new messages