필터 지우기
필터 지우기

Simulink: Mask parameter fails to bind to block port

조회 수: 1 (최근 30일)
Lucas Ritzdorf
Lucas Ritzdorf 2024년 4월 15일
댓글: Lucas Ritzdorf 2024년 4월 17일
I'm currently working with a MATLAB Function block inside of Simulink, and I'd like to expose one of the function's arguments as a parameter in the Simulink UI. A mask seems to be the usual way of doing this, but upon adding a mask, it doesn't "bind" to the underlying block's port, as I would have expected.
Is this normal? If not, how might I go about troubleshooting this? If so, how can I prevent later users from connecting normal Simulink signals to the exposed port?
For reference, here are my mask parameters, as well as the underlying block (with the masked port exposed):
  댓글 수: 2
Fangjun Jiang
Fangjun Jiang 2024년 4월 15일
I am not following. "expose one of the function's arguments", what argument? what do you mean by "expose"?
Lucas Ritzdorf
Lucas Ritzdorf 2024년 4월 16일
The underlying MATLAB function has an argument (which appears as a port on the Simulink block) that specifies how many outputs it should produce. In the screenshot above, this is 24 — and for now, that's a hard-coded value inside the function. However, I'd actually like it to appear as a mask parameter, in the configuration parameters dialog that most standard Simulink blocks provide when double-clicked.

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

채택된 답변

Fangjun Jiang
Fangjun Jiang 2024년 4월 16일
  1. It is more involved for this task. I hope the attached model (in R2022b) make it easier.
  2. In your model, the two inports are called input arguments, the two outports are called output arguments.
  3. You need to make "num_outputs" as a "parameter data", not "input data".
  4. You need to make "output" variable size and specify the max value as 24.
  5. Make a mask and pass down the value for "num_outputs"
  6. Run simulation and you will see 5 elements are non-zoro. Double click the masked MATLAB Function block, change the value from 5 to 3 to see the output display.
  댓글 수: 1
Lucas Ritzdorf
Lucas Ritzdorf 2024년 4월 17일
Perfect, thanks! That makes a lot more sense, and has made port binding work the way I'd expect.
Also, a note for anyone who might come across this later: if you need a parameter like this to be constant throughout the simulation (especially for code-generation purposes), be sure to un-check the "tunable" option for the parameter, which is found in the Model Explorer.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Create Block Masks에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by