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

6 views (last 30 days)
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

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This bug has been fixed in Release 14 Service Pack 2 (R14SP2). For previous releases, please read below for any possible workarounds:
We have verified that there is an error in the "Limitations on Indexing Operations" section of the documentation associated with the Embedded MATLAB Function block in Simulink 6.1 (R14SP1).
The correct version of the documentation should read as follows:
* 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

More Answers (0)

Categories

Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange

Products


Release

R14SP1

Community Treasure Hunt

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

Start Hunting!