how to interconnect different handles in GUi
1 view (last 30 days)
Show older comments
I have 3 text box in GUi. Basically, user needs to input a value in Box#1, Box#2 and Box#3 will do the calculation.
function edit1_Callback(hObject, eventdata, handles)
A = get(handles.edit1,'String');
B = str2num(A);
C=2+B;
set(handles.edit2,'String',num2str(C));
function edit3_Callback(hObject, eventdata, handles)
D = C+3.5;
set(handles.edit2,'String',num2str(D));
My question is how can we read a variable from another callback function if we do not set 'C' as handles in 'edit2'? In other word, I do not want to have Box2.
Thanks.
0 Comments
Answers (1)
Walter Roberson
on 2 Oct 2015
You cannot read a variable from another callback function unless you have stored the value of the variable somewhere.
Perhaps you want
function edit3_Callback(hObject, eventdata, handles)
A = get(handles.edit1,'String');
B = str2num(A);
C = 2 + B;
D = C + 3.5;
set(handles.edit3,'String',num2str(D));
2 Comments
See Also
Categories
Find more on Interactive Control and Callbacks 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!