How to list all the blocks in a model programmatically?

Is there a command to get all the blocks and their paths of a model in a list?

 Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 2 de Sept. de 2021
Editada: MathWorks Support Team el 27 de Sept. de 2021
To get a list of all the blocks in a model programmatically, please execute the following commands in the command prompt:
>> load_system('model_name')
>> bl = getfullname(Simulink.findBlocks('model_name'))
For more information on using this function please refer to the following documentation:
The above "Simulink.findBlocks" command also finds the following types of blocks:
  • Blocks under masks.
  • Blocks that are commented out.
  • Variants of blocks.
But this does not find blocks that are present inside a library linked block. To find such type of blocks you have to create a "findOptions" object and set the "FollowLinks" option to "true".
To find more information about this please refer to the following documentation:
 

Más respuestas (0)

Categorías

Más información sobre Simulink Functions en Centro de ayuda y File Exchange.

Productos

Versión

R2018a

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by