How to keep the value of certain variables as it is while switching PopUp menu option and updating other variable value?

1 view (last 30 days)
Hello Everyone,
I have designed a Matlab Gui using guide, with a popupmenu, one update push button and two edit box. Let say, I want to update four variables a, b, c, d. For case 1 of the pop up menu, a and b will be updated with my two edit box value. For case 2, c and d will be u[dated with same edit tool box. I can do that. but, I also want to keep the previous values of a and b, while updating c and d also. But, i am failing to do so, since with case 1, matlab deals with only a and b, and with case 2, it deals with c and d.. But, After updating I want to keep all four variables,
My code for push button is given below:
function pushbutton1_Callback(hObject, eventdata, handles)
contents = get(handles.popupmenu1,'String');
popupmenu1value = contents{get(handles.popupmenu1,'Value')};
switch popupmenu1value
case 'ML'
a = str2num(get(handles.edit1, 'String'));
b = str2num(get(handles.edit2, 'String'));
a
b
case 'CL'
c = str2num(get(handles.edit1, 'String'));
d = str2num(get(handles.edit2, 'String'));
c
d
a
b
end
So, even during case two, I would like to have a and b with the values of case 1, when they were updated with push button earlier.
Thanks in Advance.

Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!