フィルターのクリア

Enumerated Data Type in MATLAB

1 回表示 (過去 30 日間)
Peeyush
Peeyush 2011 年 6 月 17 日
I want to define a enumerated data type (eMatType) which consists of the following definitions :
STEEL = 1
CONCRETE = 2
ALUMINUM = 3
Now, once that data type is created, how can I use it to declare a variable. eg. if I want to delclare a variable as 'double', I use x = zeros(1,1,'double')
How can I declare a variable with the new enumerated data type?
Thanks.

採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 6 月 17 日

その他の回答 (1 件)

Laura Proctor
Laura Proctor 2011 年 6 月 17 日
Do you mean something like this?
x = nominal([3:-1:1,1,1,3],{'Steel','Concrete','Aluminum'})
  1 件のコメント
Peeyush
Peeyush 2011 年 6 月 17 日
Thanks, but I am looking for creating a new instance of a enumerated data type.
for example, if you want to initialize a variable of the type string, you write:
x = '';
if you want to initialize a variable of the type 'int32', you write:
y = zeros(1,1,'int32');
I am looking for a way to initialize a variable of the new enumerated data type 'MatType' where the class definition for 'MatType' is:
classdef(Enumeration) MatType < Simulink.IntEnumType
enumeration
MATERIAL_STEEL(1);
MATERIAL_CONCRETE(2);
MATERIAL_NODESIGN(3);
MATERIAL_ALUMINUM(4);
MATERIAL_COLDFORMED(5);
MATERIAL_REBAR(6);
MATERIAL_TENDON(7);
end
end

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEnumerations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by