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:
- Open the model.
- On matlab's prompt, call get_param('block1/Subsystem', 'revision') -- the answer is '1'
- 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.
- To confirm this, call get_param('block1/Subsystem', 'revision') before closing the dialog from the matlab prompt again -- the answer is '2'
- Now press OK to close the dialog box
- On matlab prompt, call get_param('block1/Subsystem', 'revision') -- the answer is '1', but expected is '2' as was shown in (4)
- Now press Ctrl-D to update the diagram
- 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
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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!