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))

75 views (last 30 days)
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 Comment
omar Elkawokgy
omar Elkawokgy on 27 Jul 2020
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"

Sign in to comment.

Answers (1)

Fangjun Jiang
Fangjun Jiang on 27 Jul 2020
change the storage class to "auto".
  2 Comments
Fangjun Jiang
Fangjun Jiang on 25 Oct 2023
"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.

Sign in to comment.

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!