How can I read any initialization data from mat file in standalone simulink aplication?

2 次查看(过去 30 天)
Hi,
I have a model with some parameters (gain, amplitude, simulation stop time ...), which are initialized by InitFcn callback. In this callback I read parameters from mat file. Simulink simulation is OK. But after code generation to exe file (with rsim.tlc target file) parameters are not initialized with my mat file. How can I solve my problem? Thanks,
Mirec

采纳的回答

Ketan
Ketan 2012-10-7
The simulation stop time can be selected by using the '-tf' flag when calling the rsim exe. For example :
>>!myRSimModel.exe -tf 100.0
You should be able to set parameter values of the model using a MAT file with the '-p' flag. Check out the sections "Create a MAT-File That Includes a Model Parameter Structure" and "Change Block Parameters for an RSim Simulation" in the following doc page :
  4 个评论
Miroslav
Miroslav 2012-10-18
My model parameters (gains, constants...) are initializing with very large structure (gain1 value = par.gain.gain1, gain2 value = par.gain.gain2, gain3 value = par.gain.gain3, constant1 value = par.constant.constant1, constant2 value = par.constant.constant2.......). When I get a model parameter structure with rsimgetrtp() function, all model parameters value are in a vector. How can I identify model parameters in this vector? I mean, how can I find index of gain1 value, gain2 value... in this vector?
Ketan
Ketan 2012-10-26
Hi Miraslov,
I don't think you can do this if your parameter values are stored within a MATLAB struct. You may want to change the architecture of the model from a structure containing values for all parameters to individual workspace variables for each parameter. After doing this you should be able to determine the mapping between values in the vector and parameters. You will need first enable Inline Parameters and configure the parameters that should be tunable. After doing this calling RSIMGETRTP with 'AddTunableParamInfo' set to 'on' will create additional fields within the parameter structure that define the mapping between parameters and entries. Please see the doc page for RSIMGETRTP for more info on this.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by