Configure the parameters as arguments of the step function
조회 수: 8 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Jesús Zambrano
2020년 1월 9일
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
Jesús Zambrano
2020년 1월 16일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Deployment, Integration, and Supported Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!