Simulink.findBlocks error The first input must be a system name or handle.
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
Les Beckham
2023-8-11
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?
回答(1 个)
C B
2023-8-12
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subsystems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!