Input a structure variable to a Matlab Function block

12 ビュー (過去 30 日間)
J Chen
J Chen 2019 年 5 月 3 日
回答済み: Jason Chen 2019 年 5 月 4 日
How can I input a structure variable (struct data type) to a Matlab Function block? The document states that I specify the parameter as input in the Matlab Function block and use a Bus Creator to feed the Matlab Function. How can I feed the variable to the Bus Creator? What should I use for the <object name> in the Ports and Data Manager?

回答 (1 件)

Jason Chen
Jason Chen 2019 年 5 月 4 日
Following the following steps to use a structure variable in the base workspace in a Matlab Function:
  1. Double click the Matlab Function block to open it in the Editor. Click the Edit Data icon, third from the right at the tool bar, to open the Port and Data Manager
  2. In the Port and Data Manager, add a data with the name of the variable in the base workspace
  3. Set the Scope for the data as Parameter. UNCHECK Tunable (very important)
  4. Set the Size: -1, Complexity: Inherited, Type: Inherited: Same as Simulink
  5. click Apply
The structure variable will show up as a function input argument.

カテゴリ

Help Center および File ExchangeInteractive Model Editing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by