How to access a workspace variable (or structure) by a symbolic mask parameter?

1 回表示 (過去 30 日間)
Martin
Martin 2014 年 11 月 10 日
コメント済み: Orion 2014 年 11 月 10 日
I am using a masked m-File in Simulink where I use a filed ParamName. This ParmName contains a string which is giving the name of a structure in the workspace. E.g. ParamName 'Test' in the workspace I would have a structure like Test.Val: uint16 value Test.DebVal: uint16 value Test.DebMethod: string How can I change the values of Test in the m-function? The parameter I can access in the m-function is ParamName, but it is not possible to have a command like 'ParamName.Val=12;' which would set Test.Val=12.

回答 (1 件)

Orion
Orion 2014 年 11 月 10 日
編集済み: Orion 2014 年 11 月 10 日
Not sure to get you problem.
You want to create a masked block and Initialize it with a script ?
Something like ?
see attached corresponding files.
  2 件のコメント
Martin
Martin 2014 年 11 月 10 日
In principal yes. The Subsystem would be a m-Script. The name of the structure could be changed by user since the function would be used for different variables.
Orion
Orion 2014 年 11 月 10 日
The Subsystem would be a m-Script
Do you mean a Matlab Function block ?
In all cases, whatever the content of your subsystem is, when you define a mask, you can reuse your block with a differaent parameter, that's the purpose of masks.
With the block I attached, just by pasting it and by defining a new variable, I get :

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

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by