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

1 view (last 30 days)
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 Comments
Pascal Knappe
Pascal Knappe on 29 Jul 2022
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".

Sign in to comment.

Accepted Answer

Pascal Knappe
Pascal Knappe on 22 Aug 2022
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!

More Answers (0)

Categories

Find more on Software Development Tools in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!