필터 지우기
필터 지우기

Dynamic mask creation - input values

조회 수: 2 (최근 30일)
João Araújo
João Araújo 2022년 6월 10일
답변: T.Nikhil kumar 2023년 10월 23일
Hello, I am trying to create a mask where it could take the input from a port or from a dialog and allow to select it. I tried the mask initialization code but couldn't get it to change anything:
freqsw = get_param(gcb,'inputopt');
switch freqsw
case 'Input Port'
replace_block([gcb '/Constant5'],'built-in/Constant','built-in/InPort','noprompt');
case 'Dialog'
replace_block([gcb '/Constant5'],'built-in/InPort','built-in/Constant','noprompt');
end
Can you point me to any examples or give any hints on how to do this?
Thank you

답변 (1개)

T.Nikhil kumar
T.Nikhil kumar 2023년 10월 23일
Hello João Araújo,
As per my understanding, you want to create a mask for a block with a parameter that can have ‘Input Port’ or ‘Dialog’ as its value and based on this value, you want to execute a code snippet.
You can use the Simulink Mask Editor to create the required mask for your block. Please follow the below mentioned steps to achieve the goal:
  • Right-click on the block and select "Create Mask" in the ‘Mask’ section to open the Mask Editor.
  • In this Mask Editor, open the "Parameters & Dialog". Drag a “popup” type field from the left side ‘parameter’ gallery and drop into the "Parameters & Dialog" tab. Set the “prompt” field to a meaningful name like “Frequency Switch”.
  • You can then specify a list of options in the "Type Options" property in separate lines, for example 'Input Port’ ;Dialog'.
  • In the "Callback" field, you can enter the code that should be executed when the parameter value changes. Here, you can implement your logic to replace the block based on the selected option.
  • You can then save the mask and close the editor.
Now, when you double-click on the block, you should see the mask dialog with the desired selectable options for the “Frequency Switch” parameter. On selecting an option, corresponding code will get executed in the callback function.
Refer to the following documentation to understand more about creating callback functions in a mask:
Hope this helps you proceed further!

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by