Meaning code setDatType RefMdl

조회 수: 2 (최근 30일)
Achraf
Achraf 2022년 12월 25일
댓글: Walter Roberson 2023년 1월 3일
Hello everyone, could someone explain to me what this function mean ? Thank you in advance
function setDataType(ConstantHdl)
BlockName=get_param(ConstantHdl,'Name');
is_ev=~isempty(regexp(BlockName,'^EV_\w*','once'));
if is_ev
if strcmp(get_param(ConstantHdl,'BlockType'),'Constant')
set_param(ConstantHdl,'OutDataTypeStr','Inherit: Inherit via back propagation');
else
set_param(ConstantHdl,'OutDataTypeStr','Inherit: auto');
end
else
is_prm=~isempty(regexp(BlockName,'^\w*_prm_\w*','once'));
if is_prm
prefix_regexp='^\w*_prm';
else
prefix_regexp='^\w*';
end
is_bool=~isempty(regexp(BlockName,sprintf('%s_(%s)[A-Z]\\w*',prefix_regexp,'b'),'once'));
is_int=~isempty(regexp(BlockName,sprintf('%s_(%s)[A-Z]\\w*',prefix_regexp,'ct|idx|no|st'),'once'));
is_int8=~isempty(regexp(BlockName,sprintf('%s_(%s)[A-Z]\\w*',prefix_regexp,'bf'),'once'));
if is_int
set_param(ConstantHdl,'OutDataTypeStr','int32');
elseif is_bool
set_param(ConstantHdl,'OutDataTypeStr','boolean');
elseif is_int8
set_param(ConstantHdl,'OutDataTypeStr','int8');
elseif ~isempty(regexp(BlockName,'\w*_[A-Za-z]\w*','once'))
set_param(ConstantHdl,'OutDataTypeStr','single');
else
if strcmp(get_param(ConstantHdl,'BlockType'),'Constant')
set_param(ConstantHdl,'OutDataTypeStr','Inherit: Inherit via back propagation');
else
set_param(ConstantHdl,'OutDataTypeStr','Inherit: auto');
end
end
end
set_param(ConstantHdl,'AttributesFormatString','type=%<OutDataTypeStr>');
end
  댓글 수: 1
Walter Roberson
Walter Roberson 2023년 1월 3일
It is rude to delete all of your comments in a thread; doing that removes all of the context for what the volunteers contributed.

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

채택된 답변

Kiran Kintali
Kiran Kintali 2022년 12월 25일
This code is looking for specific block name patterns and based on block name assigning output types for the blocks.
  댓글 수: 3
Walter Roberson
Walter Roberson 2022년 12월 26일
Are you asking us to look through the list of blocks on the right hand side of that image, and figure out what the patterns are in the block names that match the datatypes given in the middle, and tell you what new regexp patterns you should use?
Walter Roberson
Walter Roberson 2022년 12월 28일
is_int=~isempty(regexp(BlockName,sprintf('%s_(%s)[A-Z]\\w*',prefix_regexp,'ct|idx|no|st'),'once'));
Currently, the |st part says that if the block name matches _st then this block is an example of an integer block.
If you want to change that so that st blocks are single instead of integer, then remove the |st part of the expression, making it
is_int=~isempty(regexp(BlockName,sprintf('%s_(%s)[A-Z]\\w*',prefix_regexp,'ct|idx|no'),'once'));

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Use COM Objects in MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by