Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to provide trajectories in Simulink (RTW)?

Subject: How to provide trajectories in Simulink (RTW)?

From: Eric

Date: 27 Jan, 2010 08:50:05

Message: 1 of 6

Hello!

I have to use some trajectories (in time) within a simulink model. I don't want to use the look-up-table provided in simulink, because, as far as I understand, it only works with scalar values. I had to use plenty of them, and this would be very unhandy.

The "from workspace"-block in Simulink would be nearly perfect, but I have to restart the trajectories during the execution of the simulink-model. Is there any way to reset the time for this block, or for a subsystem in which this block could be placed? Or do you have any suggestions how to handle look-up tables (in "resetable" time) for vectors (and matrices)?
I want to create code with the rtw, therefore I cannot use the "matlab-function"-block with interp1.

If not, there's another question: Can I use some higher data-types or classes like struct or cells within an c-s-function if I want to create code with the rtw?

Eric

Subject: How to provide trajectories in Simulink (RTW)?

From: Ralph Schleicher

Date: 27 Jan, 2010 21:15:38

Message: 2 of 6

"Eric" <noemail@noemail.com> writes:

> I have to use some trajectories (in time) within a simulink model. I
> don't want to use the look-up-table provided in simulink, because, as
> far as I understand, it only works with scalar values. I had to use
> plenty of them, and this would be very unhandy.

Hi Eric,

no, lookup tables are IMHO vectorized. See the Simulink documentation.

> If not, there's another question: Can I use some higher data-types or
> classes like struct or cells within an c-s-function if I want to
> create code with the rtw?

No, you can only use scalars, vectors, and matrices. All non-double
numeric arrays, e.g. character arrays and logical arrays, will be
converted into C data type 'real_T'.

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

Development * Consulting * Training
Mathematical Modeling and Simulation
Software Tools

Subject: How to provide trajectories in Simulink (RTW)?

From: Eric

Date: 28 Jan, 2010 16:53:04

Message: 3 of 6

Hi Ralph, thanks for your answers!

But according to the documentation only 1-by-n vectors for both the input values and the data table are supported for the "Simulink->Lookup Tables->Lookup Table"-Block.
Which version of Simulink do you refer to? I use Simulink 7.0 (2007b).

Best regards,
Eric

Subject: How to provide trajectories in Simulink (RTW)?

From: Ralph Schleicher

Date: 28 Jan, 2010 21:53:46

Message: 4 of 6

"Eric" <noemail@noemail.com> writes:

> But according to the documentation only 1-by-n vectors for both the
> input values and the data table are supported for the
> "Simulink->Lookup Tables->Lookup Table"-Block. Which version of
> Simulink do you refer to? I use Simulink 7.0 (2007b).

Hi Eric,

I always use the "nD Lookup Table" block, even for 1D and 2D lookup
tables. You can fine tune interpolation, extrapolation, caching...
It's available since Matlab 6 IIRC.

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

Development * Consulting * Training
Mathematical Modeling and Simulation
Software Tools

Subject: How to provide trajectories in Simulink (RTW)?

From: Eric

Date: 1 Feb, 2010 13:16:05

Message: 5 of 6

Ralph Schleicher <rs+usenet@ralph-schleicher.de> wrote in message
> [...]
> I always use the "nD Lookup Table" block, even for 1D and 2D lookup
> tables. You can fine tune interpolation, extrapolation, caching...
> It's available since Matlab 6 IIRC.
> [...]

Hi Ralph,

I think I haven't described my problem well enough. I have some matrices, which depend on the time (e.g. the feedforward input, a regulator matrix, ...). Therefore, I need a look-up-table with a scalar input (time) and a m x n (matrix) output. The "nD Lookup Table" can handle more than one input, but I couldn't specifiy a data-matrix, such that the output is a vector or matrix. I.e., the "nD Lookup Table" represent a function of type
     scalarvalue = f(scalar1, scalar2, ...)
whereas I have a function of type
     vectorvalue = f(scalar)

I just solved the problem by creating my own c-s-function, considering the hint from your first reply. (But I'm always interested in learning how it would have been easier.)

Thanks,
Eric

Subject: How to provide trajectories in Simulink (RTW)?

From: Ralph Schleicher

Date: 1 Feb, 2010 23:45:58

Message: 6 of 6

"Eric" <noemail@noemail.com> writes:

> Therefore, I need a look-up-table with a
> scalar input (time) and a m x n (matrix) output.

Hi Eric,

aah, I see. I thought you're looking for a 'z = f(y, x)' lookup
table where x, y, and z are matrices.

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

Development * Consulting * Training
Mathematical Modeling and Simulation
Software Tools

Tags for this Thread

No tags are associated with this thread.

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.

Contact us