Thread Subject: EML and matrix/vector slices

Subject: EML and matrix/vector slices

From: Olaf

Date: 24 Sep, 2009 13:19:17

Message: 1 of 3

Hi,

in Simulink I'm using Embedded Matlab function blocks with a function
like this:

function [Q, R, ...] =
foo(k, Q_1, R_1, ...)

    ...
    [Q_1(1:k,1:k), R_1(1:k, :)] = ...;
    ...

end

where Q_1 means Q(k-1) - the previous time step data etc. I've got the error

Could not determine the size of this expression.

Function ... : "1:k"

k is an external count variable and therefore not known on entry of this
function. Aren't matrix slices not supported as this? The code self
works as matlab script without problems. How can I get it EML too?
Basicly, on each step k the matrices Q and R are updated - therefore I
have to use aliases resp. slices.

Thanks,
Olaf

Subject: EML and matrix/vector slices

From: Guy Rouleau

Date: 24 Sep, 2009 22:54:02

Message: 2 of 3

Olaf <noreplay@inder.net> wrote in message <h9frkl$15e$1@fuerst.cs.uni-magdeburg.de>...
> Hi,
>
> in Simulink I'm using Embedded Matlab function blocks with a function
> like this:
>
> function [Q, R, ...] =
> foo(k, Q_1, R_1, ...)
>
> ...
> [Q_1(1:k,1:k), R_1(1:k, :)] = ...;
> ...
>
> end
>
> where Q_1 means Q(k-1) - the previous time step data etc. I've got the error
>
> Could not determine the size of this expression.
>
> Function ... : "1:k"
>
> k is an external count variable and therefore not known on entry of this
> function. Aren't matrix slices not supported as this? The code self
> works as matlab script without problems. How can I get it EML too?
> Basicly, on each step k the matrices Q and R are updated - therefore I
> have to use aliases resp. slices.
>
> Thanks,
> Olaf

Hi,

In R2009a and before, EML does not support variable sizing. all the dimensions of all arrays must be known before the simulation starts (EML generates C-code, and in c all dimensions must be declared). the only workaround is to declare a large array and use only part of it in your algorithm,

In R2009b variables-size signals have been introduced in simulink and EML. This one of the most important new feature in my opinion.

So you should be able to run your code in R2009b. If not, only small modification should be necessary. Please search the online doc for "Variable-size signals" for mroe details.

Guy

Subject: EML and matrix/vector slices

From: Olaf

Date: 25 Sep, 2009 05:29:17

Message: 3 of 3

>> in Simulink I'm using Embedded Matlab function blocks with a function
>> like this:
>>
>> function [Q, R, ...] =
>> foo(k, Q_1, R_1, ...)
>>
>> ...
>> [Q_1(1:k,1:k), R_1(1:k, :)] = ...;
>> ...
>>
>> end
>>
>> where Q_1 means Q(k-1) - the previous time step data etc. I've got the error
>>
>> Could not determine the size of this expression.
>>
>> Function ... : "1:k"
>>
>> k is an external count variable and therefore not known on entry of this
>> function. Aren't matrix slices not supported as this? The code self
>> works as matlab script without problems. How can I get it EML too?
>> Basicly, on each step k the matrices Q and R are updated - therefore I
>> have to use aliases resp. slices.

> In R2009a and before, EML does not support variable sizing. all the dimensions of all arrays must be known before the simulation starts (EML generates C-code, and in c all dimensions must be declared). the only workaround is to declare a large array and use only part of it in your algorithm,

and how to in detail? I've a IniFcn wich contains:

Ts = 1e-6;
Tend = 1e-3;

m = 3;
n = 3;

N = Tend/Ts + 1;
sz = m + n + 1;
Q0 = zeros(N, N);
R0 = zeros(N, sz);

As you can see, I allocated a large array before and pass them to the
EML function - inside I want to write only on parts of them - which
fails (maybe I use the wrong syntax for EML?)

> In R2009b variables-size signals have been introduced in simulink and EML. This one of the most important new feature in my opinion.
>
> So you should be able to run your code in R2009b. If not, only small modification should be necessary. Please search the online doc for "Variable-size signals" for mroe details.

Cool, thanks for the hint. Anyway, the preferred way is to use the
approach mentioned above with R2009a ;-)

Thanks,
Olaf

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