このページの翻訳は最新ではありません。ここをクリックして、英語の最新版を参照してください。
Simulink.interface.dictionary.DataElement
説明
データ要素は、送信データの構造やインターフェイスのその他の分解など、データ インターフェイスの各部分を記述したものです。
作成
Simulink.interface.dictionary.DataElement
オブジェクトを作成するには、関数 addElement
を使用して既存の Simulink.interface.dictionary.DataInterface
オブジェクトにデータ要素を追加します。
dataElementObj = addElement(dataInterfaceObj,"element")
既存のデータ要素には関数 getElement
を使用してアクセスできます。
プロパティ
Name
— データ要素の名前
文字ベクトル | string スカラー
データ要素の名前。文字ベクトルまたは string スカラーとして指定します。
データ型: char
| string
Type
— データ要素のタイプ
Simulink.interface.dictionary.ValueType
オブジェクト
データ要素のタイプ。Simulink.interface.dictionary.ValueType
オブジェクトとして指定します。
Description
— データ要素の説明
文字ベクトル | string スカラー
データ要素の説明。文字ベクトルまたは string スカラーとして指定します。
データ型: char
| string
Dimensions
— データ要素の次元
文字ベクトル
データ要素の次元。要素の次元を含む 2 要素ベクトルを表す文字ベクトルとして指定します。
データ型: char
Owner
— データ要素を含むデータ インターフェイス
Simulink.interface.dictionary.DataInterface
オブジェクト
データ要素を含む Simulink.interface.dictionary.DataInterface
オブジェクト。
例
データ インターフェイスのデータ要素の追加と削除
この例では、データ インターフェイスのデータ要素にアクセスする方法と追加および削除する方法を示します。
既存のインターフェイス ディクショナリを開きます。これにより、Simulink.interface.Dictionary
オブジェクト interfaceDictObj
が作成されます。
interfaceDictObj = Simulink.interface.dictionary.open('myInterfaceDict.sldd')
interfaceDictObj = Dictionary with properties: DictionaryFileName: 'myInterfaceDict.sldd' Interfaces: [1x1 Simulink.interface.dictionary.DataInterface] DataTypes: [0x0 Simulink.interface.dictionary.DataType]
このインターフェイス ディクショナリには、データ インターフェイス定義が 1 つ含まれています。
interfaceObj = interfaceDictObj.Interfaces
interfaceObj = DataInterface with properties: Name: 'interface1' Description: '' Elements: [1x2 Simulink.interface.dictionary.DataElement] Owner: [1x1 Simulink.interface.Dictionary]
データ インターフェイスは、データ インターフェイスの各部分を記述するデータ要素で構成されます。このインターフェイス定義に含まれるデータ要素は 2 つです。
interfaceObj.Elements(1)
ans = DataElement with properties: Name: 'element1' Type: [1x1 Simulink.interface.dictionary.ValueType] Description: '' Dimensions: '1' Owner: [1x1 Simulink.interface.dictionary.DataInterface]
interfaceObj.Elements(2)
ans = DataElement with properties: Name: 'element2' Type: [1x1 Simulink.interface.dictionary.ValueType] Description: '' Dimensions: '1' Owner: [1x1 Simulink.interface.dictionary.DataInterface]
関数 addElement
を使用してデータ インターフェイスに新しいデータ要素を追加します。
dataElem1 = addElement(interfaceObj, 'element3')
dataElem1 = DataElement with properties: Name: 'element3' Type: [1x1 Simulink.interface.dictionary.ValueType] Description: '' Dimensions: '1' Owner: [1x1 Simulink.interface.dictionary.DataInterface]
既存のデータ要素には関数 getElement
を使用してアクセスできます。
dataElem3 = getElement(interfaceObj, 'element3')
dataElem3 = DataElement with properties: Name: 'element3' Type: [1x1 Simulink.interface.dictionary.ValueType] Description: '' Dimensions: '1' Owner: [1x1 Simulink.interface.dictionary.DataInterface]
関数 removeElement
を使用してインターフェイスからデータ要素を削除します。
removeElement(interfaceObj, 'element3')
バージョン履歴
R2022b で導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)