Can Simscape models be build programmatically?

조회 수: 4 (최근 30일)
Claudius Rosendahl
Claudius Rosendahl 2022년 9월 27일
댓글: Claudius Rosendahl 2022년 9월 28일
I want to build a Simscape model for thermal liquids programmatically.
sim_name='pipes';
if exist(sim_name,'file') == 4
% If it does then check whether it's open
if bdIsLoaded(sim_name)
% If it is then close it (without saving!)
close_system(sim_name,0)
end
% delete the file
delete([sim_name,'.mdl']);
end
new_system(sim_name)
y=50;
add_block(['Simscape/Foundation Library/Thermal Liquid/Elements/Pipe (TL)'], [sim_name,'/pipes'],'Position', [140+x 95 170+x 125]);
this throws the error There is no block named 'Simscape/Foundation Library/Thermal Liquid/Elements/Pipe (TL)'
Caused by:
Error using untitled8
Unable to load block diagram 'Simscape'
For blocks ordered under Simulink in the Library Browser, this problem does not occur.
Is there any way to build simscape models programmatically?

채택된 답변

Fangjun Jiang
Fangjun Jiang 2022년 9월 27일
I tried this and the block was added. To figure out for other blocks, open the library file, select the block and run "gcb" in MATLAB Command Window
add_block('fl_lib/Thermal Liquid/Elements/Pipe (TL)', ...)
  댓글 수: 3
Fangjun Jiang
Fangjun Jiang 2022년 9월 28일
At the library browser, select any library, right click, select "Open ..."
Claudius Rosendahl
Claudius Rosendahl 2022년 9월 28일
awesome, thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Foundation and Custom Domains에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by