Thread Subject: Noob: How to use a variable as parameter in SS-model???

Subject: Noob: How to use a variable as parameter in SS-model???

From: Volker Klink

Date: 1 Dec, 2008 14:04:01

Message: 1 of 5

Hi!
I'm quite experienced with MatLab but not with Simulink...
So this is probably very simple for you guys:

I have a state-space-block in Simulink which requires to define the matrices A,B,C,D.
Normally you define these matrices directly in the Function Block Properties with numeric values. But I would like to define these matrices with values, called a and b, which I have calculated with another block.
The ss-block only has one input and one output for the x and u vector. So I can't get my a and b into the ss-block by connecting it with lines....

When I try to run the model Simulink complains, that a and b are unknown variables...

Thanks!

Subject: Noob: How to use a variable as parameter in SS-model???

From: Mathieu C.

Date: 1 Dec, 2008 15:04:04

Message: 2 of 5

Hello,
Are you using the sim command? If so, have you checked the default source and destination workspaces (see the simset documentation).
Mathieu

"Volker Klink" <volker.v.klinkNOSPAM@daimler.com> wrote in message <gh0qsh$alp$1@fred.mathworks.com>...
> Hi!
> I'm quite experienced with MatLab but not with Simulink...
> So this is probably very simple for you guys:
>
> I have a state-space-block in Simulink which requires to define the matrices A,B,C,D.
> Normally you define these matrices directly in the Function Block Properties with numeric values. But I would like to define these matrices with values, called a and b, which I have calculated with another block.
> The ss-block only has one input and one output for the x and u vector. So I can't get my a and b into the ss-block by connecting it with lines....
>
> When I try to run the model Simulink complains, that a and b are unknown variables...
>
> Thanks!

Subject: Noob: How to use a variable as parameter in SS-model???

From: Volker Klink

Date: 1 Dec, 2008 15:38:02

Message: 3 of 5

> Are you using the sim command? If so, have you checked the default source and destination workspaces (see the simset documentation).

Well, I tried not to use a MatLab script at all....
But I guess I have to check that out...

Subject: Noob: How to use a variable as parameter in SS-model???

From: Mathieu C.

Date: 1 Dec, 2008 15:59:03

Message: 4 of 5

Hello,
Then, I don't see the problem. If you have for instance a gain which is set for instance to "a+b", and that a and b have not been defined in mask or model workspaces, then Simulink looks for a and b in the base workspace (if you launched your simulation using the "play" button) to evaluate the expression. So you just need to define a and b in the base workspace. Have you built the model yourself? Does the model have any callbacks that clear the workspace?
Mathieu


"Volker Klink" <volker.v.klinkNOSPAM@daimler.com> wrote in message <gh10cq$br6$1@fred.mathworks.com>...
> > Are you using the sim command? If so, have you checked the default source and destination workspaces (see the simset documentation).
>
> Well, I tried not to use a MatLab script at all....
> But I guess I have to check that out...

Subject: Noob: How to use a variable as parameter in SS-model???

From: Seth Popinchalk

Date: 6 Dec, 2008 14:43:02

Message: 5 of 5

"Volker Klink" <volker.v.klinkNOSPAM@daimler.com> wrote in message <gh0qsh$alp$1@fred.mathworks.com>...
> Hi!
> I'm quite experienced with MatLab but not with Simulink...
> So this is probably very simple for you guys:
>
> I have a state-space-block in Simulink which requires to define the matrices A,B,C,D.
> Normally you define these matrices directly in the Function Block Properties with numeric values. But I would like to define these matrices with values, called a and b, which I have calculated with another block.
> The ss-block only has one input and one output for the x and u vector. So I can't get my a and b into the ss-block by connecting it with lines....
>
> When I try to run the model Simulink complains, that a and b are unknown variables...
>
> Thanks!

If you have your A, B, C and D calculated on signal lines, you should just build the equations with base blocks. Integrator, matrix multiply, sum. The state space block uses constant values for A, B, C and D. It sounds like your values are not constant so the State Space block is not right for your system.

Seth Popinchalk

Check out my Simulink blog: http://blogs.mathworks.com/seth/
Senior Applications Engineer
The MathWorks, Inc.

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 Seth Popinchalk 6 Dec, 2008 09:46:37
parameter Volker Klink 1 Dec, 2008 09:05:07
state space Volker Klink 1 Dec, 2008 09:05:07
simulink Volker Klink 1 Dec, 2008 09:05:07
rssFeed for this Thread

Contact us at files@mathworks.com