Thread Subject: Scope of 'To Workspace' variables

Subject: Scope of 'To Workspace' variables

From: Hans Gohle

Date: 25 May, 2008 21:01:02

Message: 1 of 9

Hi,

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?

Thanks,

g.

Subject: Scope of 'To Workspace' variables

From: Ralph Schleicher

Date: 26 May, 2008 23:21:42

Message: 2 of 9

"Hans Gohle" <ghostryder@gmx.de> writes:

> 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, Freelance Engineer http://ralph-schleicher.de

Development * Consulting * Training
Mathematical Modeling and Simulation
Software Tools

Subject: Scope of 'To Workspace' variables

From: Hans Gohle

Date: 27 May, 2008 07:54:02

Message: 3 of 9

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.

Hopefully I described my problem a bit better...

Thanks, g.

Subject: Scope of 'To Workspace' variables

From: helper

Date: 27 May, 2008 11:25:03

Message: 4 of 9

I'm not sure I follow exactly, but maybe the ASSIGNIN and
EVALIN functions would help you?

Subject: Scope of 'To Workspace' variables

From: Hans Gohle

Date: 27 May, 2008 11:47:02

Message: 5 of 9

"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...

Subject: Scope of 'To Workspace' variables

From: Omur Bas

Date: 27 May, 2008 12:20:04

Message: 6 of 9

"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.

Omur Bas
www.promodsoftware.com.tr

Subject: Scope of 'To Workspace' variables

From: Hans Gohle

Date: 27 May, 2008 12:24:02

Message: 7 of 9

"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...

Subject: Scope of 'To Workspace' variables

From: Hans Gohle

Date: 27 May, 2008 12:41:02

Message: 8 of 9

"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!

Subject: Scope of 'To Workspace' variables

From: Aditya K

Date: 29 Nov, 2008 23:40:17

Message: 9 of 9

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
>

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
simulink Omur Bas 27 May, 2008 08:20:48
data log Omur Bas 27 May, 2008 08:20:48
rssFeed for this Thread

Contact us at files@mathworks.com