How do I add a custom library to a model using a script?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Patricia
le 26 Mar 2014
Réponse apportée : Kaustubha Govind
le 27 Mar 2014
Hi all,
I have a custom block library and I want to generate the source code. I know how to do in manually by creating a model and dragging and dropping all blocks into the new model before generating the code.
Now I want to do it automatically by using a script. So my question is how do I add the library to the model on a script?
My library is called LIB_MAT and I tried using add_block but it says it can't find the block.
load_system('gen_model');
load_system('LIB_MAT');
set_param('LIB_MAT', 'Lock', 'off');
add_block('LIB_MAT', 'gen_model')
add_block returns "There is no block named 'LIB_MAT'".
Thanks in advance,
Patricia
0 commentaires
Réponse acceptée
Kaustubha Govind
le 27 Mar 2014
You need to specify the block name, not just the model/library name. For example:
add_block('LIB_MAT/A', 'gen_model/A')
You can get the full list of blocks in your library using something like:
blockNames = find_system('LIB_MAT', 'Type', 'Block'); %returns cell array of block paths
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Sources dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!