How to use variables in a subsystem mask

Hi!
I am working on a subsystem mask that changes its outputs depending on a popup. The thing is that I have to know which was the previous popup item selected to do one change or another.
I am doing it by using one parameter of the mask. It works when it is shown in the mask ( show parameter checked), but when I hide it (I don't want to see this variable) it stop working properly.
Is there any way to use variables instead of parameters to do that?
Many thanks!

8 Comments

How does the user change the pop-up value if it is invisible?
There is the pop-up and the parameter working as a variable. The pop-up can be changed by the user but not the variable (which is changed by the pop-up callback). The variable is blocked for the user.
Dani: Are you saying that the hidden parameter stores the previous value of the visible popup parameter? If so, how do you access the previous value from the dialog callback?
Yes. When I change the pop-up value, it reads which was the previous pop-up value stored in the hidden parameter/variable. Then it executes the proper modifications and then updates the hidden parameter/variable with the actual pop-up value to be ready for the next change (if any).
How do you read the previous value exactly? I thought that get_param returns the new value when called from the parameter callback?
Yes, it returns the new value, when I need to know the previous one. For this reason I need to use another parameter to store which was the previous pop-up value and at the end of the callback I store the new value. The parameter where I store the previous value shouldn't be modifiable by the mask. This is the code by the way, topology is the pop-up parameter and previous_topology is where I save the previous pop-up value:
% Pop-up callback
previous_topology = get_param(gcb,'previous_topology');
if strcmp(get_param(gcb,'topology'),'Num. 1')
switch previous_topology
case '2'
% Execute changes when coming from Topology 2...
case '3'
% Execute changes when coming from Topology 3...
end
set_param(gcb,'previous_topology','1');
elseif strcmp(get_param(gcb,'topology'),'Num. 2')
switch previous_topology
case '1'
% Execute changes when coming from Topology 1...
case '3'
% Execute changes when coming from Topology 3...
end
set_param(gcb,'previous_topology','2');
elseif strcmp(get_param(gcb,'topology'),'Num. 3')
switch previous_topology
case '1'
% Execute changes when coming from Topology 1...
case '2'
% Execute changes when coming from Topology 2...
end
set_param(gcb,'previous_topology','3');
end
Is going to help me someone? I still having problems with the use of this parameter as a variable.
Many thanks!
I tried your code in 2017a, and it worked fine if you deselect the 'visible' check box of the mask parameter.

Sign in to comment.

Answers (0)

Categories

Products

Asked:

on 17 Jun 2013

Commented:

on 2 Aug 2017

Community Treasure Hunt

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

Start Hunting!