MATLAB: How to read any initialization data from mat file in standalone simulink aplication

code generationinitializationread datasimulation stop timesimulink coder

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

Best Answer

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 :