Get old and new values in callback editor(Mask)

9 vues (au cours des 30 derniers jours)
Yakov M
Yakov M le 4 Mai 2019
I have a costum block created in my library I have created a costum dialog box.Every time that user enter a new value I like that the some values inside a block will be updated so I tried to use a callback that allows run matlab command on every change.But its not clear how do I get an access for an old value and a new value in dialog box.

Réponse acceptée

Jared Belke
Jared Belke le 27 Juin 2019
Everytime the value of a mask parameter is changed, that parameter's callback code is executed. If you want to access the newly entered value, you can do so as follows:
get_param(gcb, '<Parameter Name>') % gcb is a function that stands for "get current block"
If you also need the previous value for some reason, you need to store that value somewhere else and update it manually each time the user changes the parameter. For example say you have some parameter in your mask called Param1, and each time the user changes Param1 you need access to both the new value and the previous value. You could have an extra parameter in your mask that is invisible to the user (Make sure the 'Visible' Field is unchecked for that parameter in the mask editor), called "OldParam1" or something like that. Everytime the user changes Param1, then in your callback you can access the new value with:
newValue = get_param(gcb, 'Param1');
and you can access the old value with:
oldValue = get_param(gcb, 'OldParam1');
Once you've done what you need to with the old value you can update it to the current value with:
set_param(gcb, 'OldParam1', newValue);
That way, the next time the user changes Param1, OldValue will contain the most recent previous value.

Plus de réponses (0)

Catégories

En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by