How do I create a Simulink model from the MATLAB command line?
조회 수: 14 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2016년 12월 1일
편집: MathWorks Support Team
2025년 2월 4일
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
2025년 1월 24일
편집: MathWorks Support Team
2025년 2월 4일
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 run the following command in the command window of MATLAB R2020b to access the release-specific documentation:
>> web(fullfile(docroot, 'simulink/slref/add_block.html'))
Additionally, for more information regarding 'add_line', you can use the command below:
>> web(fullfile(docroot, 'simulink/slref/add_line.html'))
An overarching documentation page regarding Simulink blocks, which includes modifying the parameters programmatically with 'get_param' and 'set_param', can be accessed by running the following command:
>> web(fullfile(docroot, 'simulink/blocks.html'))
Please follow the below link to search for the required information regarding the current release:
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!