Meaning code setDatType RefMdl

6 visualizzazioni (ultimi 30 giorni)
Achraf
Achraf il 25 Dic 2022
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 Commento
Walter Roberson
Walter Roberson il 3 Gen 2023
It is rude to delete all of your comments in a thread; doing that removes all of the context for what the volunteers contributed.

Accedi per commentare.

Risposta accettata

Kiran Kintali
Kiran Kintali il 25 Dic 2022
This code is looking for specific block name patterns and based on block name assigning output types for the blocks.
  3 Commenti
Walter Roberson
Walter Roberson il 26 Dic 2022
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 il 28 Dic 2022
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'));

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Use COM Objects in MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by