Can Simscape models be build programmatically?
5 ビュー (過去 30 日間)
Claudius Rosendahl 2022 年 9 月 27 日
I want to build a Simscape model for thermal liquids programmatically.
I took some code from https://www.goddardconsulting.ca/simulink-creating-using-matlab-code.html#BuildingAModel and adapted it.
if exist(sim_name,'file') == 4
% If it does then check whether it's open
% If it is then close it (without saving!)
% delete the file
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)'
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 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)', ...)