I use m file which initialize parameters in MATLAB workspace.
It is example of file:
Pconstant=Simulink.Parameter;
Pconstant.Value=3;
Pconstant.CoderInfo.StorageClass = 'exportedGlobal';
Pgain=Simulink.Parameter;
Pgain.Value=10;
Pgain.CoderInfo.StorageClass = 'exportedGlobal';
These parameters are used as value in 'Gain' and 'Constant' blocks. I generate c source code for this model and received following structure in model_data.c file:
/* Block parameters (auto storage) */
P_ParameterTest_T ParameterTest_P = {
10.0, /* Expression: Pgain
* Referenced by: '<Root>/Gain'
*/
3.0, /* Expression: Pconstant
* Referenced by: '<Root>/Constant'
*/
};
Model.h file contains following code:
/* Parameters (auto storage) */
struct P_ParameterTest_T_ {
real_T Gain_Gain; /* Expression: Pgain
* Referenced by: '<Root>/Gain'
*/
real_T Constant_Value; /* Expression: Pconstant
* Referenced by: '<Root>/Constant'
*/
};
Model source code compiling into model.a lib file which is used in other programs. I can change value of constant in external c code:
parameters = (BLOCK_PARAMETERS*)rtmGetDefaultParam(model);
parameters->Constant_Value = 1;
But this solution is not good for me. Because I do not know where are used these parameters and I do not know fields names of structure.
Can I write code which will be set value in all fields of structure where are used Pconstant parameter? Something like this:
Pconstant = 1; //instead of parameters->Constant_Value = 1;
Thanks for help.