How to make a Simulink Parameter non-tunable to avoid the following error: Parameter 'InputPortWidth' of '' is non-tunable but refers to tunable variables (NUM_OF_FAULT_EVENTS (base workspace))

76 ビュー (過去 30 日間)
I have the following defined in my base workspace by a .m file at startup:
NUM_OF_FAULT_EVENTS = Simulink.Parameter;
NUM_OF_FAULT_EVENTS.Value = 35;
NUM_OF_FAULT_EVENTS.CoderInfo.StorageClass = 'Custom';
NUM_OF_FAULT_EVENTS.CoderInfo.Alias = '';
NUM_OF_FAULT_EVENTS.CoderInfo.Alignment = -1;
NUM_OF_FAULT_EVENTS.CoderInfo.CustomStorageClass = 'Define';
NUM_OF_FAULT_EVENTS.CoderInfo.CustomAttributes.HeaderFile = '';
NUM_OF_FAULT_EVENTS.CoderInfo.CustomAttributes.ConcurrentAccess = false;
NUM_OF_FAULT_EVENTS.CoderInfo.Alias = '';
NUM_OF_FAULT_EVENTS.CoderInfo.Alignment = -1;
NUM_OF_FAULT_EVENTS.Description = 'The number of fault events';
NUM_OF_FAULT_EVENTS.DataType = 'uint8';
NUM_OF_FAULT_EVENTS.Min = [];
NUM_OF_FAULT_EVENTS.Max = [];
NUM_OF_FAULT_EVENTS.DocUnits = '';
This Parameter is used to define the "Input port size:" of a Selector block with the following options selected:
Number of input dimensions: set to 1
Index Mode: set to "Zero-based"
Index Option: set to "Index vector(port)"
Input port size: set to NUM_OF_FAULT_EVENTS
I get the following error when I build the model for code generation:
Invalid setting in '<model path>/Selector' for parameter 'InputPortWidth'.
Caused by:
Parameter 'InputPortWidth' of '<model path>/Selector' is non-tunable but refers to tunable variables (NUM_OF_FAULT_EVENTS (base workspace))
My question is:
How do I force the the NUM_OF_FAULT_EVENTS parameter to be non-tunable in my base workspace using the .m file when the model project is loaded?
  1 件のコメント
omar Elkawokgy
omar Elkawokgy 2020 年 7 月 27 日
As far as I know you should only define it as variable not a Simulink parameter
NUM_OF_FAULT_EVENTS = uint8(35);
Also do not forget to set Configuration Parameters => Optimization => Signals and Parameters => Default parameter behavior: "Inline"

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

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2020 年 7 月 27 日
change the storage class to "auto".
  2 件のコメント
ruili
ruili 2023 年 10 月 25 日
It's work , but do you know reason?
Fangjun Jiang
Fangjun Jiang 2023 年 10 月 25 日
"InputPortWidth" should be non-tunable. It is possible to use CustomStorageClass "Define" to define it but the setting seems to be incomplete. For example, the usually needed header file is empty. Use 'auto' storage class is the easiest solution.

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

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

タグ

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by