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))
78 次查看(过去 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
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
2020-7-27
change the storage class to "auto".
2 个评论
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 Exchange 中查找有关 Data Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!