Custom Simscape/Simulink Library

2 ビュー (過去 30 日間)
Ryan Zeoli
Ryan Zeoli 2015 年 9 月 24 日
回答済み: David John 2025 年 6 月 12 日
Hello,
How can I make a custom library populated with Simscape foundational blocks, user defined Simscape blocks, user defined subsystems, and Simulink blocks (such as the scope)?
Currently, I can add all of the above to a custom library, but if I add another custom block and rebuild with ssc_build, the simulink blocks disappear and must be added by dragging again. I would like to build a custom library with all necessary components to send to other users.
All computers using the model and library have MATLAB2015a and relevant Toolboxes installed.
Thanks for the help! -Ryan

回答 (1 件)

David John
David John 2025 年 6 月 12 日
Consider adding an sl_postprocess.m file to your library directory, sl_postprocess - Make postprocessing customizations when building custom block library - MATLAB. It will run as part of your call to ssc_build.
For example, in 25a, you could have a post-processing file with the following content to add the Foundation Resistor block to your custom library:
function sl_postprocess(h)
% Check if the handle is valid
if isempty(h) || ~ishandle(h)
error('Invalid handle provided.');
end
% Add the Simscape Foundation Resistor block to the custom library
try
% Add the Resistor block to the model
add_block('fl_lib/Electrical/Electrical Elements/Resistor', ...
[get_param(h, 'Name') '/Resistor']);
catch ME
error('Failed to add Resistor block: %s', ME.message);
end
end

カテゴリ

Help Center および File ExchangeFoundation and Custom Domains についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by