Borrar filtros
Borrar filtros

Simulink.findBlocks error The first input must be a system name or handle.

6 visualizaciones (últimos 30 días)
checker
checker el 11 de Ag. de 2023
Editada: checker el 12 de Ag. de 2023
Greetings,
Setup: create a model with a constant block in it.
Select the constant block
Type the following command:
Simulink.findBlocks(gcbh,'BlockType','Constant')
and get the error
Error using Simulink.findBlocks
The first input must be a system name or handle.
Caused by:
Error using Simulink.findBlocks
The first input is an object of type 'Constant block'.
This seems to apply to all native (unmasked) simulink library blocks which normally wouldn't be a problem but I have a masked block ('Mask' is 'On' but there is no masked subsystem, just some custom parameters) which returns the same error. Is there a particular parameter I can examine to sort this out?
Setting aside the inconsistent behavior of this function to emphasize my question, is there a block parameter that I can use to differentiate between a masked block with no subsystem and a masked block with a subsystem?
Thanks
-Chris
  2 comentarios
Les Beckham
Les Beckham el 11 de Ag. de 2023
I don't understand why you are trying to "find" the current block (gcbh is a handle to the currently selected block).
Simulink.findBlocks is for searching in a model (system) to find blocks of a specified type. The error message is pretty clear about this.
What are you really trying to do?
checker
checker el 12 de Ag. de 2023
I use this to search thru masked blocks to find blocks of interest under the mask and it does that just fine for all but native simulink blocks and a masked blocks that have custom parameters only (no masked subsystem). The function accepts a handle and gcbh returns a handle. The error in this case is far from clear in that it says gcbh is object of type 'Constant block'! It's type is double and it's a handle to the block, hence my question. A consistent behavior would be to return an empty array with no error. I can achieve my goal by using find_system but that's an older function and I like the prototype of Simulink.findBlocks better.

Iniciar sesión para comentar.

Respuestas (1)

C B
C B el 12 de Ag. de 2023
As it shows
Error using Simulink.findBlocks
The first input must be a system (name or handle).
So it is basically asking for system name or handle which should be model name or subsystem.
To solve this instead of selecting constant block.
Select the SubSystem
And Enter your command
Simulink.findBlocks(gcbh,'BlockType','Constant')
Please let me know if this is not what you want.
  1 comentario
checker
checker el 12 de Ag. de 2023
Thanks for the response. I don't see anywhere in the docs that translates 'name or handle' into 'model name or subsystem'. Obviously I'm using this command in a larger script that parses models for certain information so selecting a subsystem simply isn't an option. See my response to the other question for additional detail.

Iniciar sesión para comentar.

Categorías

Más información sobre Subsystems en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by