I have a model that contains several 'To Workspace' outputs.
The execution of the model is done within a function and
therefore these variables are only visible within that
function.
But I need all these variables in the workspace as they are
needed by a GUI that is executed concurrently and plots the
data from the model. What is the best way to share the data
between the model and the GUI?
> I have a model that contains several 'To Workspace' outputs.
> The execution of the model is done within a function and
> therefore these variables are only visible within that
> function.
>
> But I need all these variables in the workspace as they are
> needed by a GUI that is executed concurrently and plots the
> data from the model. What is the best way to share the data
> between the model and the GUI?
Do you look for somethink like that:
function a_function
sim('a_model');
% Propagate workspace variables.
my_gui('sim-data', a, b, c);
function my_gui(varargin)
switch varargin{1}
case 'sim-data'
a = varargin{2};
b = varargin{3};
c = varargin{4};
end
Ralph Schleicher <rs@ralph-schleicher.de> wrote in message
<87iqx0mz21.fsf@echo.mueller-schleicher.i>...
> Do you look for somethink like that:
>
>
> function a_function
> sim('a_model');
> % Propagate workspace variables.
> my_gui('sim-data', a, b, c);
>
>
> function my_gui(varargin)
> switch varargin{1}
> case 'sim-data'
> a = varargin{2};
> b = varargin{3};
> c = varargin{4};
> end
I'm sorry but I don't think that I have stated my problem
correctly. I'll give it one more try:
I'm executing a model in 'scope' mode which means that I set
the simulation time to 'inf'. In that model there are
several 'To Workspace' variables. The problem is that I need
the values of these blocks during the simulation time.
So I need any mechanism with that I can forward the
simulation data to my GUI during the simulation itself.
"helper " <spamless@nospam.com> wrote in message
<g1gr2f$s6j$1@fred.mathworks.com>...
> I'm not sure I follow exactly, but maybe the ASSIGNIN and
> EVALIN functions would help you?
I know these functions. But I need variables from a running
model (Simulink) in the workspace although the model is
still running... So I think the 'assignin' and 'evalin'
functions don't help me unless I use s-functions to transfer
the data to workspace...
"Hans Gohle" <ghostryder@gmx.de> wrote in message
<g1gsbm$868$1@fred.mathworks.com>...
> "helper " <spamless@nospam.com> wrote in message
> <g1gr2f$s6j$1@fred.mathworks.com>...
> > I'm not sure I follow exactly, but maybe the ASSIGNIN and
> > EVALIN functions would help you?
>
> I know these functions. But I need variables from a running
> model (Simulink) in the workspace although the model is
> still running... So I think the 'assignin' and 'evalin'
> functions don't help me unless I use s-functions to transfer
> the data to workspace...
>
You must issue a WriteLogs command from a function or the
command line to get the data logged up until that point
while the simulation is running.
"helper " <spamless@nospam.com> wrote in message
<g1gr2f$s6j$1@fred.mathworks.com>...
> I'm not sure I follow exactly, but maybe the ASSIGNIN and
> EVALIN functions would help you?
I know these functions. But I need variables from a running
model (Simulink) in the workspace although the model is
still running... So I think the 'assignin' and 'evalin'
functions don't help me unless I use s-functions to transfer
the data to workspace...
"Omur Bas" <omur.bas@promodxxxxxx.com.tr> wrote in message
<g1gu9k$o6d$1@fred.mathworks.com>...
> "Hans Gohle" <ghostryder@gmx.de> wrote in message
> <g1gsbm$868$1@fred.mathworks.com>...
> > "helper " <spamless@nospam.com> wrote in message
> > <g1gr2f$s6j$1@fred.mathworks.com>...
> > > I'm not sure I follow exactly, but maybe the ASSIGNIN and
> > > EVALIN functions would help you?
> >
> > I know these functions. But I need variables from a running
> > model (Simulink) in the workspace although the model is
> > still running... So I think the 'assignin' and 'evalin'
> > functions don't help me unless I use s-functions to transfer
> > the data to workspace...
> >
>
> You must issue a WriteLogs command from a function or the
> command line to get the data logged up until that point
> while the simulation is running.
>
> set_param(modelname,'SimulationCommand','WriteDataLogs')
>
> I hope this answers your question.
Thanks a lot! That's EXACTLY what I was looking for!
Hi,
I am using Simulink v6.0 (R14) and
set_param(modelname,'SimulationCommand','WriteDataLogs')
fails with an error message that that 'WriteDataLogs' is an invalid setting. I suspect that my version does not support this value of SimulationCommand.
I want to monitor active states of a Stateflow chart "during" the simulation. If I just log the signals (states) then the ModelDataLog object is available in the workspace only after the simulation is over. Can anyone suggest what to do?
Thanks,
Aditya.
"Omur Bas" <omur.bas@promodxxxxxx.com.tr> wrote in message <g1gu9k$o6d$1@fred.mathworks.com>...
> You must issue a WriteLogs command from a function or the
> command line to get the data logged up until that point
> while the simulation is running.
>
> set_param(modelname,'SimulationCommand','WriteDataLogs')
>
> I hope this answers your question.
>
> Omur Bas
> www.promodsoftware.com.tr
>
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.