Why does Embedded MATLAB fail to detemrine the size of my expression in Simulink 7.2 (R2008b)?

5 views (last 30 days)
I use the following MATLAB code in an Embedded MATLAB Function block:
function y = fcn(u)
y = eye(6);
y(1,u-1:u+1) = 2
I receive an error message similar to:
Size of index expression is not statically known.
or
Could not determine the size of this expression

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 20 Jun 2011
This enhancement has been incorporated in Release 2011a (R2011a). For previous product releases, read below for any possible workarounds:
In this case, Embedded MATLAB does not recognize that the size of the expression is constant. To workaround this issue, define a vector of indices to be used in the assignment, as in this example:
function y = fcn(u)
y = eye(6);
T = (0:2)+u-1; % Define the vector of indices to be assigned
y(1,T) = 2; % assign values in the large matrix

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2008b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!