フィルターのクリア

Changing the size of an array in a referenced masked model

5 ビュー (過去 30 日間)
Alexander Lazo
Alexander Lazo 2024 年 2 月 22 日
編集済み: Pramil 2024 年 3 月 27 日
Hello,
I have created a referenced masked model as described in:
The example only covers parameters with dimensions [1 1] but it can also be applied to other dimensions. My problem is, whenever the matlab variable is created and set as an argument in the model workspace the dimensions of the default value also get stored. Whenever insert my model reference in a specific context and try to set a parameter with a different dimension to the default value, I get the following error:
Invalid setting in mainModel/myRefModel for parameter x
caused by: invalid dimensions for parameter argument 'x' of model block 'mainModel/myRefModel'. The parameter provided is a [1x41] array but a [1x2] array is expected.
Unfortunately, for my application, I need the lenght of my array to be variable (it will change from mainModel to mainModel).

回答 (1 件)

Pramil
Pramil 2024 年 3 月 27 日
編集済み: Pramil 2024 年 3 月 27 日
As of MATLAB R2023b there is no possible way to pass value into a parameter of a masked model with dimensions other than the one set initially.
Now, there is a work-around, you can create masked subsystems instead of masked models as they are more flexible with respect to parameter dimensions.
You can follow these steps to create one:
  1. Open a “Blank Subsystem”.
  2. Add all the necessary blocks and make the required connections.
  3. Right click and select Mask -> Create System Mask.
  4. Create the mask by defining your parameters.
  5. Now open your “MainModel” and add a “Subsystem Reference” block and reference your masked subsystem.
This will allow you to pass values with desired dimensions.
I have attached an example model that works for MATLAB R2022b that you can refer.

カテゴリ

Help Center および File ExchangeCreate Block Masks についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by