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