How to get simulink library and block names for the add_block function?
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
I would like to create a Simulink model programatically, using commands such as add_block etc. However, I'm having trouble finding out the correct names for the libraries and blocks in the libraries. As a specific example I have tried to add a Level-2 M-File S-Function with a command similar to the following:
add_block('simulink/User-defined Functions/M-S-Function', 'mymodel/thesfunction')
This however gives the error:
??? There is no block named 'simulink/User-defined Functions/M-S-Function'
It's also not clear whether I have to first load the User-defined Functions library first in this case. So I'm not sure if I have got the name of the library wrong, or something else.
In general how do I find the correct library name and block name for adding the block to a model programatically?
Risposta accettata
Ryan G
il 17 Set 2012
I bet this is because the Simulink library is not loaded. Try doing this first:
load_system('simulink');
5 Commenti
pj110
il 24 Set 2015
I have the same problem but I want to add a '/Asynchronous Machine SI Units' but I get the error " There is no block named 'Simscape/SimPowerSystems/Second Generation/Machines/Asynchronous Machine SI Units' is this any way that I can use add_block() function for other toolboxes in simulink library such as Simscape and ...
Regards,
Pj
pj110
il 24 Set 2015
Good news I found it. Bad news the gcb commands give different path and names for each component in SimPowerSystem but by finding the root library path you can add the name of the any of the components you get the block on your mdl or xls file.
for example gcb command for the selected component gave me below: powerlib/Machines/Simplified Synchronous Machine pu Units however it was not the Simplified Synchronous Machine pu Units so I write the firs to part of the path and then I added the name of the component that I want. whatever it works for me but the gcb command is not operate correctly by choosing the component from the library and typin gcb on command window it gives different names for that component. now I use add_block and use powerlib/machines and append the correct name for my component to get the desired block on my mdl file. it has worked for me. for other toolbox it seems the same problem.
pj
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Simulink Functions in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!