필터 지우기
필터 지우기

Simulink.f​indBlocksO​fType for Multiple Types

조회 수: 10 (최근 30일)
Gerrit
Gerrit 2019년 10월 28일
댓글: Gerrit 2019년 11월 1일
The function Simulink.findBlocksOfType finds blocks of one type (e.g. 'Mux') in a Simulink subsystem or model. Is there a direct way to find a set of blocks of multiple types (e.g. 'Mux' and 'Demux') in a model? I tried passing a cell array with two values:
blockhandles = Simulink.findBlocksOfType(sys, {'Mux', 'Demux'});
However, this resulted, as was to be expected based on the Simulink.findBlocksOfType help, in an error message:
Error using Simulink.internal.findBlocksOfType
Invalid input for argument 2 (rhs2):
Value must be a character vector or string scalar.
Thus, is there a way to do a single search for multiple block types in the spirit of the attempt above, or do I need to repeat the search for each individual block type?

채택된 답변

Fangjun Jiang
Fangjun Jiang 2019년 10월 28일
vdp;
Option=Simulink.FindOptions('RegExp',true);
Simulink.findBlocks('vdp', 'BlockType','Gain|Outport',Option)
  댓글 수: 1
Gerrit
Gerrit 2019년 11월 1일
I see you're having me look into 'regular expressions' now; every day is a school day. It works well, so thanks!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by