How to find MATLAB function blocks??

조회 수: 11 (최근 30일)
TT DD
TT DD 2021년 7월 5일
답변: N/A 2024년 8월 7일
Dear Community, can i get the answer to this question?
S = sfroot();
% Get block
handlesB = find(sfroot, '-isa','Stateflow.EMChart');
This is the instruction I have used to find out the MATLAB Function blocks. But, this instruction also considers the MATLAB Function block present the the Simulink library. I would like to know whether there is any other command to find out MATLAB Function blocks which are just present in my created Model.

답변 (2개)

Yongjian Feng
Yongjian Feng 2021년 7월 5일
Once you find the root of state flow using sfroot, you can use the find function as you used above. In addtion you can add a new name-value pair if you know the name of the block.
Something like
find(sfroot, '-isa', 'Stateflow.EMChart', 'Name', 'MyBlock');
  댓글 수: 1
TT DD
TT DD 2021년 7월 6일
Thank you so much for the answer. I have tried using these instructions as well, but it looks it doesnot work.
Using this instruction I am able to find the MATLAB function block. Although the issue is that it also gives the MATLAB function block when there is no MATLAB function block present in my model. I am surprised that, to which MATLAB function block is it referring to when there is no function block in the created model.

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


N/A
N/A 2024년 8월 7일
rt = sfroot; % stateflow root
A = rt.find('-isa','Stateflow.EMChart', 'Path', gcb); % Find the selected Simulink Matlab Function block (without the Path property, this will display all Matlab Function blocks)
B = A.outputs(1).Name; % Get the name of the 1st outport
fprintf(1,'\n%s output %d is called %s',gcb, 1, B);
fprintf(1,'\n');

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by