Filter löschen
Filter löschen

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

3 Ansichten (letzte 30 Tage)
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 Kommentar
Varun Jadhav
Varun Jadhav am 28 Okt. 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)?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Sebastian Castro
Sebastian Castro am 28 Okt. 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

Weitere Antworten (0)

Kategorien

Mehr zu Electrical Block Libraries finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by