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

1 vue (au cours des 30 derniers jours)
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

Réponse acceptée

Ketan
Ketan le 7 Oct 2012
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 commentaires
Miroslav
Miroslav le 18 Oct 2012
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 le 26 Oct 2012
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by