Borrar filtros
Borrar filtros

How to input the sample time of model (.slx file) from a .m file?

3 visualizaciones (últimos 30 días)
Hello, I want to integrate the model and the .m file together such that I don't have to open the model file to make the necessary changes. The only two parameters I need to change are Simulation end time and Sample time. While I have found a way to edit simulation end time using the sim('model', [0 sim_end]) command, I cant seem to find the way to control the sample time (powergui/configure parameters/solver/simulation type: discrete/sample time). Please help
  1 comentario
Varun Jadhav
Varun Jadhav el 28 de Oct. de 2015
I found a way, putting the sampling time in the script and defining it with a variable, & putting that variable name in the "Sample Time" space. But is there a way to choose the simulation type (discrete/continuous) and solvers (TBE/Tustin/Backward Euler)?

Iniciar sesión para comentar.

Respuesta aceptada

Sebastian Castro
Sebastian Castro el 28 de Oct. de 2015
Yes, this is possible using the set_param function. Note that the powergui block changed in R2015a (I believe) to be more "Simulink-like", so I'm working off the latest version when I tried this out.
To change the model's stop time is a global model setting, so you can do something like:
>> modelName = 'myModel';
>> load_system(modelName);
>> set_param(modelName,'StopTime','50')
To change the powergui block properties, you have to use the block name. For example:
>> blockName = 'myModel/powergui'; % You can obtain this by selecting the block and typing gcb
>> set_param(blockName,'SimulationMode','Discrete')
>> set_param(blockName,'SolverType','Tustin/Backward Euler (TBE)')
>> set_param(blockName,'SampleTime','1e-6')
- Sebastian

Más respuestas (0)

Categorías

Más información sobre Electrical Block Libraries en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by