Thread Subject: How to pass structure from work space to simulink?

Subject: How to pass structure from work space to simulink?

From: naresh

Date: 12 Nov, 2009 22:36:03

Message: 1 of 7


Hi,

I am new to Simulink but know Matlab well and have been using it since long. I wanted to pass a structure Q having fields (Q.a, Q.b,......, etc) of matrices and vectors of different sizes to Simulink from Matlab work space. It would be appreciable, if some one suggest the way out.

Thank You
Nash

Subject: How to pass structure from work space to simulink?

From: Guy Rouleau

Date: 13 Nov, 2009 00:38:02

Message: 2 of 7

"naresh " <nnandola@asu.edu> wrote in message <hdi2kj$rpt$1@fred.mathworks.com>...
>
> Hi,
>
> I am new to Simulink but know Matlab well and have been using it since long. I wanted to pass a structure Q having fields (Q.a, Q.b,......, etc) of matrices and vectors of different sizes to Simulink from Matlab work space. It would be appreciable, if some one suggest the way out.
>
> Thank You
> Nash

Hi,

Not sure what you mean here... If you want a field of the structure to be used as a block parameter, then just type it there. If you want to pass it to an s-function, then you need to know a little about mxArrays. If you are talking about an input signal, then you need to use an inport and specify the name of the structure un teh configuration parameter dialog of the model.

Let me know if you are talking about something else!

Subject: How to pass structure from work space to simulink?

From: naresh

Date: 13 Nov, 2009 16:55:21

Message: 3 of 7

"Guy Rouleau" <guy.rouleau.nospam@mathworks.com> wrote in message <hdi9pa$bsh$1@fred.mathworks.com>...
> "naresh " <nnandola@asu.edu> wrote in message <hdi2kj$rpt$1@fred.mathworks.com>...
> >
> > Hi,
> >
> > I am new to Simulink but know Matlab well and have been using it since long. I wanted to pass a structure Q having fields (Q.a, Q.b,......, etc) of matrices and vectors of different sizes to Simulink from Matlab work space. It would be appreciable, if some one suggest the way out.
> >
> > Thank You
> > Nash
>
> Hi,
>
> Not sure what you mean here... If you want a field of the structure to be used as a block parameter, then just type it there. If you want to pass it to an s-function, then you need to know a little about mxArrays. If you are talking about an input signal, then you need to use an inport and specify the name of the structure un teh configuration parameter dialog of the model.
>
> Let me know if you are talking about something else!

Hi,
Thanks a lot for the reply.

 I am sorry that my question was not clear to you. Now, let me be more specific.
I am using "Embeded Matlab function" block from simulink library. Now i want to use few parameters inside this block and i want to supply theses parameters from work space (or m file). These parameters are constant vectors/matrices. I have number of such parameters which i am able to supply separately using "constant" block for each of them. But with this my simulink file looks too crowded therefore i want to supply all these parameters using a structure (which i created in workspace and these parameters are the fields of this structure ) .

Thank you
Naresh

Subject: How to pass structure from work space to simulink?

From: naresh

Date: 13 Nov, 2009 16:56:20

Message: 4 of 7

"Guy Rouleau" <guy.rouleau.nospam@mathworks.com> wrote in message <hdi9pa$bsh$1@fred.mathworks.com>...
> "naresh " <nnandola@asu.edu> wrote in message <hdi2kj$rpt$1@fred.mathworks.com>...
> >
> > Hi,
> >
> > I am new to Simulink but know Matlab well and have been using it since long. I wanted to pass a structure Q having fields (Q.a, Q.b,......, etc) of matrices and vectors of different sizes to Simulink from Matlab work space. It would be appreciable, if some one suggest the way out.
> >
> > Thank You
> > Nash
>
> Hi,
>
> Not sure what you mean here... If you want a field of the structure to be used as a block parameter, then just type it there. If you want to pass it to an s-function, then you need to know a little about mxArrays. If you are talking about an input signal, then you need to use an inport and specify the name of the structure un teh configuration parameter dialog of the model.
>
> Let me know if you are talking about something else!

Hi,
Thanks a lot for the reply.

 I am sorry that my question was not clear to you. Now, let me be more specific.
I am using "Embeded Matlab function" block from simulink library. Now i want to use few parameters inside this block and i want to supply theses parameters from work space (or m file). These parameters are constant vectors/matrices. I have number of such parameters which i am able to supply separately using "constant" block for each of them. But with this my simulink file looks too crowded therefore i want to supply all these parameters using a structure (which i created in workspace and these parameters are the fields of this structure ) .

Thank you
Naresh

Subject: How to pass structure from work space to simulink?

From: naresh

Date: 13 Nov, 2009 16:57:03

Message: 5 of 7

"Guy Rouleau" <guy.rouleau.nospam@mathworks.com> wrote in message <hdi9pa$bsh$1@fred.mathworks.com>...
> "naresh " <nnandola@asu.edu> wrote in message <hdi2kj$rpt$1@fred.mathworks.com>...
> >
> > Hi,
> >
> > I am new to Simulink but know Matlab well and have been using it since long. I wanted to pass a structure Q having fields (Q.a, Q.b,......, etc) of matrices and vectors of different sizes to Simulink from Matlab work space. It would be appreciable, if some one suggest the way out.
> >
> > Thank You
> > Nash
>
> Hi,
>
> Not sure what you mean here... If you want a field of the structure to be used as a block parameter, then just type it there. If you want to pass it to an s-function, then you need to know a little about mxArrays. If you are talking about an input signal, then you need to use an inport and specify the name of the structure un teh configuration parameter dialog of the model.
>
> Let me know if you are talking about something else!

Hi,
Thanks a lot for the reply.

 I am sorry that my question was not clear to you. Now, let me be more specific.
I am using "Embeded Matlab function" block from simulink library. Now i want to use few parameters inside this block and i want to supply theses parameters from work space (or m file). These parameters are constant vectors/matrices. I have number of such parameters which i am able to supply separately using "constant" block for each of them. But with this my simulink file looks too crowded therefore i want to supply all these parameters using a structure (which i created in workspace and these parameters are the fields of this structure ) .

Thank you
Naresh

Subject: How to pass structure from work space to simulink?

From: Ramon Nogueron

Date: 26 Mar, 2010 12:58:04

Message: 6 of 7

Hi,

Set one of the inputs of the embedded function to be a parameter instead of input and unckeck tunnable. Use the same name for the parameter as the name of the structure variable in the workspace you want to use.
Regards.
R.

Subject: How to pass structure from work space to simulink?

From: naresh

Date: 26 Mar, 2010 17:02:05

Message: 7 of 7

"Ramon Nogueron" <ramon.nogue@gmail.com> wrote in message <hoib0s$ggl$1@fred.mathworks.com>...
> Hi,
>
> Set one of the inputs of the embedded function to be a parameter instead of input and unckeck tunnable. Use the same name for the parameter as the name of the structure variable in the workspace you want to use.
> Regards.
> R.

Hi,

Ramon thanks for the solution.

Regards,
Naresh

Tags for this Thread

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.

rssFeed for this Thread

Contact us at files@mathworks.com