Why can't find_system find IC block?

I would like to find all initial condition blocks in my Simulink model, yet the following returns an empty cell array,
thisBlock = find_system(bdroot, 'BlockType', 'IC')
Can you correct this call to find_system? When I click on the block, gcb returns 'myModel/IC', so I believe the block type is correct.

 채택된 답변

Kaustubha Govind
Kaustubha Govind 2012년 4월 13일

1 개 추천

The IC block's BlockType is 'InitialCondition', so you should be using find_system(bdroot, 'BlockType', 'InitialCondition'). I would recommend using find_system(bdroot, 'LookUnderMasks', 'on', 'BlockType', 'InitialCondition') if you want to search inside masked subsystems also.

댓글 수: 2

K E
K E 2012년 4월 16일
Thanks as always! I had thought the block name (IC) was the same as block type (IntialCondition), so good to know that they are not. In case it is helpful to someone:
1) To find the block type,
get_param(gcb,'BlockType')
2) To highlight all such blocks,
thisBlock = find_system(bdroot, 'LookUnderMasks', 'on', 'BlockType', 'InitialCondition') ;
hilite_system(thisBlock, 'find') ; % Turn highlighting on
hilite_system(thisBlock, 'none') ; % Turn highlighting off
Kaustubha Govind
Kaustubha Govind 2012년 4월 16일
Thanks for posting your complete solution!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

질문:

K E
2012년 4월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by