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

2 ビュー (過去 30 日間)
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.

採用された回答

MathWorks Support Team
MathWorks Support Team 2009 年 6 月 27 日
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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCommunications Toolbox についてさらに検索

製品


リリース

R14SP1

Community Treasure Hunt

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

Start Hunting!

Translated by