フィルターのクリア

Maximum size of output not bounded in matlab function block for linspace error

1 回表示 (過去 30 日間)
I am using matlab function block in simulink and need to use linspace for use in my function. When I run the model, I get an error saying "Computed maximum size of the output of function 'linspace' is not bounded. Static memory allocation requires all sizes to be bounded. The computed size is [1 x :?]." How do I get around this? The code where I use linspace is below where 'd't is a single value calculated earlier in the model and is imported into the block and 'n' is a constant coming from a constants block.
vec = linspace(0,dt,n)

採用された回答

Honglei Chen
Honglei Chen 2017 年 11 月 7 日
You said the value n is from a constant block, so do you ever need to change it? If the answer is no, then you can consider hard code it in the function. If you want to be able to change it from time to time but never need to change it during the model running, then you can also consider set it up as a nontunable dialog parameter so the engine knows that your vec has a fixed size.
HTH
  4 件のコメント
Andrew Poissant
Andrew Poissant 2017 年 11 月 7 日
You are right! My bad. But why would Simulink give me an error using a constants block? I preset the block to a value of 8 and do not change it so shouldn't Simulink know the size?
Honglei Chen
Honglei Chen 2017 年 11 月 7 日
All MATLAB Function block knows is that this value is coming from the input, it has no idea whether the previous block is a constant or not so it has to prepare for the worst case. (Besides, even for a constant block, I believe you can still tune the parameter during the simulation)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Environment Customization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by