Get old and new values in callback editor(Mask)
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Yakov M
am 4 Mai 2019
Beantwortet: Jared Belke
am 27 Jun. 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.
0 Kommentare
Akzeptierte Antwort
Jared Belke
am 27 Jun. 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.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Programmatic Model Editing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!