Meaning code setDatType RefMdl
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Achraf
le 25 Déc 2022
Commenté : Walter Roberson
le 3 Jan 2023
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 commentaire
Walter Roberson
le 3 Jan 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.
Réponse acceptée
Kiran Kintali
le 25 Déc 2022
This code is looking for specific block name patterns and based on block name assigning output types for the blocks.
3 commentaires
Walter Roberson
le 26 Déc 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
le 28 Déc 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'));
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!