How do I create a Simulink model from the MATLAB command line?

10 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2016 年 12 月 1 日
編集済み: MathWorks Support Team 2021 年 3 月 8 日
I need to create a Simulink model using MATLAB commands or scripts. What functions and/or utilities are available to enable me to do this? 

採用された回答

MathWorks Support Team
MathWorks Support Team 2016 年 12 月 1 日
編集済み: MathWorks Support Team 2021 年 3 月 8 日
You can create a Simulink model and add blocks/ lines to it using 'add_block' and 'add_line' commands. For example to add a Constant block which provides an input to the To Workspace block to a blank model, you can use the following MATLAB code:
 mdl='myModel';  % this is a blank model at first
  load_system(mdl);  
  add_block('built-in/Constant',[mdl '/Constant'])
  add_block('built-in/To Workspace',[mdl '/Output'],'Saveformat','Array',...
     'SampleTime','-1','VariableName','sim_out','MaxDataPoints','1');
  add_line(mdl,'Constant/1','Output/1','autorouting','on');
For more information on 'add_block'  please refer the MATLAB documentation:
and more information regarding 'add_line' can be found here:
An overarching documentation page regarding Simulink blocks, including modifying the parameters programmatically with 'get_param' and 'set_param' can be found here: 

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by