フィルターのクリア

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

3 ビュー (過去 30 日間)
Varun Jadhav
Varun Jadhav 2015 年 10 月 23 日
コメント済み: Varun Jadhav 2015 年 10 月 30 日
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 件のコメント
Varun Jadhav
Varun Jadhav 2015 年 10 月 28 日
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)?

サインインしてコメントする。

採用された回答

Sebastian Castro
Sebastian Castro 2015 年 10 月 28 日
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
  1 件のコメント
Varun Jadhav
Varun Jadhav 2015 年 10 月 30 日
Thanks a lot, Sebastian... It works... :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeElectrical Block Libraries についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by