How to pass mask parameters in a child Matlab function ?

조회 수: 11 (최근 30일)
Alexandre SAULNIER
Alexandre SAULNIER 2022년 6월 9일
댓글: Alexandre SAULNIER 2022년 6월 10일
Hello everyone,
In my model, I created a masked subsystem with many parameters (around 90 parameters). In this subsystem, I introduced a Matlab function and I need to use the parameters I defined earlier in the parent-subsystem mask to resolve equations.
The content of the parent masked-subsystem is represented in the screenshot below :
The yellow blocks correspond to blocks which use a parameter from the mask upper in the block hierarchy and these parameters are recognized. However, they're not in the Matlab function.
I looked on the help center but no topics correspond to the issue I'm encountering. I don't want to create a mask for the Matlab function with the same parameters or to add around 90 constant blocks grouped by a bus to send it to the Matlab function.
So, here is my question : why does Matlab function not recognize the mask parameters ?
I kindly thank you in advance for your answers,
Best regards
AS

채택된 답변

Fangjun Jiang
Fangjun Jiang 2022년 6월 9일
For those yellow blocks or any of the typical Simulink blocks, there is a block parameter dialog, where you can specify a variable for a parameter. This variable is usually defined in workspace, but you can mask it and provide its value through mask dialog. This is how mask works.
So you need to add a "parameter" to the MATLAB Function. Click "edit data" button at the Editor, add a data and specify it as "parameter".
  댓글 수: 3
Fangjun Jiang
Fangjun Jiang 2022년 6월 9일
If the MATLAB Function block has 80 parameters, then those parameters need to be defined by the MATLAB Function itself, to achieve the intended behavior.
If those 80 parameters need to appear in the mask dialog, then you need to mask them. There is no other way. This is already the simpliest way without the need for extra work (such as creating 80 Constant blocks and feeding them as inputs to the MATLAB Function block).
Regarding parent subsystem, you can mask a parameter that is located several levels of subsystems inside. I am not sure whether there is a constraint on non-virtual subsystems.
To mask 90 parameters is not a good UI. There is not enough screen space (even with table). I suggest using a file. The user can modify the file. The file is read in during initilization to set the parameter values.
Alexandre SAULNIER
Alexandre SAULNIER 2022년 6월 10일
Well, I should have masked the Matlab function in place of the parent subsystem. It's good to know, thank you for your reply.
There is, indeed, 80 parameters but they are not used all the time so I masked the parameters useless in some case and use tabs to make the mask easily readable by the user.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Subsystems에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by