Which function can I use to get the information of simulink.A​liasType/N​umericType in M file?

7 ビュー (過去 30 日間)
博学 黄
博学 黄 2022 年 9 月 3 日
回答済み: Andy Bartlett 2024 年 4 月 15 日
Which function can I use to get the information of simulink.AliasType/NumericType in M file?
such as for Enum class, we can use getEnumTypeInfo to get the information of Enum, i would like to know the simaliar function for Alias type and NumericType
thx

回答 (1 件)

Andy Bartlett
Andy Bartlett 2024 年 4 月 15 日
First you need to have access to the Alias Type as a variable.
If you only have the name of the alias type used by a model, then you can get a copy of the variable using slResolve
aliasTypeVariable = slResolve( aliasTypeNameString, modelNameOrHandle )
Once you have the variable, you can use fixed.extractNumericType to get the type attributes.
For example,
myAliasType1 = Simulink.AliasType;
myAliasType1.BaseType = 'fixdt(1,16,3)';
nt1 = fixed.extractNumericType( myAliasType1.BaseType)
nt1 = DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 3
myAliasType2 = Simulink.AliasType;
myAliasType2.BaseType = 'single';
nt2 = fixed.extractNumericType( myAliasType2.BaseType)
nt2 = DataTypeMode: Single
FYI: You can also use fixed.extractNumericType to get the numerictype info from other things such as numeric variable or a type name.
myNumericVar = single(pi);
nt3 = fixed.extractNumericType(myNumericVar)
nt3 = DataTypeMode: Single
nt4 = fixed.extractNumericType('ufix16_En13')
nt4 = DataTypeMode: Fixed-point: binary point scaling Signedness: Unsigned WordLength: 16 FractionLength: 13

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by