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)?
How to input the sample time of model (.slx file) from a .m file?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Varun Jadhav
il 23 Ott 2015
Commentato: Varun Jadhav
il 30 Ott 2015
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
Risposta accettata
Sebastian Castro
il 28 Ott 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
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Schedule Model Components in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!