Configure the parameters as arguments of the step function
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I'm trying to generate code where the model parameters are passed as arguments to the step function. I'm not able to find the configuration which enables this.
The step function looks like this:
extern void MODEL_step(MODEL_T *const MODEL_M, Input_Type *arg_In,Output_Type *arg_Out);
But i need something like this:
extern void MODEL_step(MODEL_T *const MODEL_M, Input_Type *arg_In,Output_Type *arg_Out, const Parameters_Type *MODEL_Parameters);
I've already tryed changing the storage clases, editing the storage clases. The closests i get is using the storage class "ImportedExternPointer". Where i get a declaration like this inj the header file:
extern Parameters_Type *MODEL_Parameters;
But this means that if i want to reuse this code N times to represent this model N times, all the N times i use the same parameters, which i don't want.
Any suggestions will be appreciated,
0 comentarios
Respuestas (1)
Jesús Zambrano
el 9 de En. de 2020
Hi Rodrigo,
When the step function looks like:
extern void MODEL_step(MODEL_T *const MODEL_M, Input_Type *arg_In,Output_Type *arg_Out);
means that you generate re-entrant multi-instance code from a model. Looking at the code you will see how parameters and states are packed in the MODEL_M structure, which is passed directly to the function interface. Therefore, multiple instances of the model_step function can run simultaneously when the step function has that prototype.
You get the above function prototype via: Code Generation > Interface > Code Interface Packaging option > set option to "Reusable function code".
Hope this answer can help you.
3 comentarios
Jesús Zambrano
el 16 de En. de 2020
Hi Rodrigo,
What you could try is to use referenced models. You create a child model with a set of parameters in its model workkspace that can be tunable (go to the Model Explorer and check the box under Arguments for those parameters). Then, in the parent, bring as many copies of your child model, then go to each call and set the value of the arguments. When generating code, each call of the child will use its own parameters.
Hope this workflow can help you.
Best,
Jesús
Ver también
Categorías
Más información sobre Deployment, Integration, and Supported Hardware en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!