Setting hidden mask variable from callback fails

22 次查看(过去 30 天)
Hello Community
I have a problem concerning hidden mask variables.
My intention is to change the value of a hidden mask variable from inside the callback of another variable in the same block mask.
Attached is an example. Open the mask editor of Subsystem. You will see under "Parameters & Dialog" there are two variables "model" and "revision", the latter is hidden. "model" has a callback that changes "revision" when modified using set_param(). However, the changed value of "revision" is not copied to the original block when the dialog is closed using OK.
To reproduce:
  1. Open the model.
  2. On matlab's prompt, call get_param('block1/Subsystem', 'revision') -- the answer is '1'
  3. Double click Subsystem to open the block paramters dialog. Choose 'EL2' from the drop down menu. This triggers the callback on "model" to set "revision" to 2 as is reported on the matlab command line.
  4. To confirm this, call get_param('block1/Subsystem', 'revision') before closing the dialog from the matlab prompt again -- the answer is '2'
  5. Now press OK to close the dialog box
  6. On matlab prompt, call get_param('block1/Subsystem', 'revision') -- the answer is '1', but expected is '2' as was shown in (4)
  7. Now press Ctrl-D to update the diagram
  8. On matlab's prompt, call get_param('block1/Subsystem', 'revision') -- the answer is '2', as expected
At the moment the work around is the model update function in step 7. But why is "revision" not updated in step 5?
When "revision" is not hidden, everything works.
Does someone have an answer? Is there a method to mark the variable as modified so that it is copied to the block upon dialog close?
  1 个评论
Oliver Jaehrig
Oliver Jaehrig about 3 hours 前
This might be a known bug in R2018a. I cannot reproduce this in R2024b.
Can you try to upgrade your release, or check if instead of using a hidden variable you can disable this and disable the Visible property and see if this works for you?

请先登录,再进行评论。

回答(0 个)

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by