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!