Why do I receive an error when I use the colon operator (:) in the Embedded MATLAB Function block as described in the documentation for Simulink 6.1 (R14SP1)?
Show older comments
The documentation associated with the Embedded MATLAB Function block in Simulink 6.1 (R14SP1), accessible by typing the following at the MATLAB prompt:
web ([docroot '/toolbox/simulink/slref/eml_blocks_ref13.html#limitations_on_indexing_operations'])
includes the following text and example:
* M(i:j) where i and j change in a loop
Embedded MATLAB never dynamically allocates memory for the size of the expressions that change as the program executes. The workaround is to use for loops as shown in the following example:
for i=1:10
for j = i:10
M(i:j) = 2 * M(i:j);
end
end
However, when I use the preceding code featuring the color operator (:) in the Embedded MATLAB function block, the following errors are returned:
Size of index expression is not statically known.
Function 'Embedded MATLAB Function' (#32.175.178), line 7, column 11:
"i:j"
Errors occurred during parsing of Embedded MATLAB function 'Embedded
MATLAB Function'(#32)
Embedded MATLAB Interface Error: Port width mismatch. Input port "u"(#36) expects a scalar. The signal is a one dimensional vector with 1 elements.
Accepted Answer
More Answers (0)
Categories
Find more on Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!