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

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

 Respuesta aceptada

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 comentarios

Thank you very much Ketan. Your answer is very usefull for me. I have a one question: In my model i have many parameters, and when I get a model parameter structure with rsimgetrtp() function, parameter values are in vector. How can I identify concrete parameters in this vector? Mirec
Hi Miroslav,
Unfortunately I am not too sure what is meant by "concrete parameters". Could you elaborate on this. An example might be helpful in addressing this.
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?
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Simulink Coder en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 2 de Oct. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by