I'm trying to embed a SimulinkGlobal Simulink.Parameter in the simulink model file. My model uses a constant "p1". If I define a Simulink.Parameter 'p1' in the MATLAB/Base workspace with CoderInfo.StorageClass of SimulinkGlobal, the behavior is what I expect: a parameter "p1" gets created in the generated code. But if I do the same thing in the Model Workspace, 'p1' gets optimized out and the generated code just uses an inline constant, which is not what I want.
Why is the Simulink.Parameter storage class seems to be ignored?
When the Simulink.Parameter is defined in the Model Workspace:
testingSimulinkParameter_Y.Out1 = testingSimulinkParameter_ConstB.Gain;
where:
const ConstBlockIO_testingSimulinkPar testingSimulinkParameter_ConstB = { 22 6.0 23 /* '<Root>/Gain' */ 24 };
When the Simulink.Parameter is defined in the Base Workspace:
testingSimulinkParameter_Y.Out1 = testingSimulinkParameter_P.p1 * 2.0;Parameters_testingSimulinkParam testingSimulinkParameter_P = { 22 3.0 /* Variable: p1 23 * Referenced by: '<Root>/Gain' 24 */ 25 };
Why is the named variable p1 lost when defined in Model Workspace? I should be able to preserve the variable name 'p1' when defining the simulink.parameter as simulinkGlobal in model workspace also. Is this a bug.
Best Answer