Using Simulink.Parameter in Matlab Function to make number of loops calibrateable

1 回表示 (過去 30 日間)
Hello,
I have a Matlab Function in Simulink, which contains a for loop. The number of loops should be calibrateable and therefore is defined by a Simulink.Parameter.
for i = 1:MySimulinkParameter_C
% do stuff
end
% **** ERROR ****
But this seems to lead to an error. In the diagnostic viewer I only get the message " **** Error **** ".
When I change the upper value to a hard coded value I get no error
for i = 1:10
% do stuff
end
% no error
Does someone know the reason for this issue or can explain, how to furter debug this?
Thanks in advance!
  2 件のコメント
Benjamin Thompson
Benjamin Thompson 2022 年 7 月 29 日
Can you attach an example model showing the problem?
Pascal Knappe
Pascal Knappe 2022 年 7 月 29 日
Hello Benjamin,
I attached an MWE. It is a little different than what I described initially because first it was difficult to reproduce the same error, but now it also appears in the MWE.
Additional information: In the MWE the error appeared only after changing the System Target File from default to "ert.tlc".

サインインしてコメントする。

採用された回答

Pascal Knappe
Pascal Knappe 2022 年 8 月 22 日
So it seems newer versions than 19b have a report tool which gives one more details about errors in Matlab Functions. Trying to compile the MWE in 20b I get the error:
So I get that the problem is, that at compile time array sizes have to be fixed and can't be changed via calibration. At least with the STF ert.tlc, which is for C-Code compilation.
Thanks to myself!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSoftware Development Tools についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by