How do I find the library block path of a built-in Simulink block to add it programmatically to my model?

45 views (last 30 days)
I want to programmatically add a Simscape Connection Port to my model. But in order to use the "add_block" command, I need to know what the library path is for the Simscape Connection Port. How can I programmatically add the port using the MATLAB command line?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 22 Apr 2021
In general, if you want to find the root library of most of the built-in blocks, you can use one of the following methods:
(1) Go to the Library Browser and hover over the block:
(2) Go to the Library Browser, right-click on the library of interest and select "Open <libraryname> library" to open the library model:
Then in the library model, select the block of interest, and enter "gcb" at the command line:
>> gcb
ans =
'nesl_utility/Connection Port'
(3) A possible programmatic solution to finding the library block path for blocks from the basic Simulink library is presented in the following MATLAB Answers post:
Finally, if your model is called "modelname", use the following command to add the built-in library block to your model:
>> add_block('nesl_utility/Connection Port','modelname/MyConnection')
Refer to the "add_block" documentation page for more information:

More Answers (0)

Categories

Find more on Event Functions in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!