Question about GUI programming
조회 수: 9 (최근 30일)
이전 댓글 표시
Hello. I am trying to make a GUI about speech recognition. i want to hold a variable from one function and use it to another one. for example. i have this code.
% --- Executes on button press in ixografisi. (record Button)
function c = ixografisi_Callback(hObject, eventdata, handles)
a = wavread('tilefwno_mix.wav');
axes(handles.axes1);
plot(a);
c = end_detection(a);
% --- Executes when selected object is changed in uipanel2.
function b = uipanel2_SelectionChangeFcn(hObject, eventdata, handles)
if (get(handles.man,'Value') == 1.0)
b = 1
else
b = 2
end
% --- Executes on button press in apotelesma. (result button)
function d = apotelesma_Callback(b, c, hObject, eventdata, handles)
if (b == 1)
g = 'm';
elseif (b == 2)
g = 'f';
end
d = demo(c,g);
I want to use the variable c from the record button and the variable b in uipanel2 in the result button. the variable b only takes 1 or 2 depends on the selection of male or female. but when i get it to the result button it has a value of 18.0032. why? can someone help me pls?
thank u
marina :)
댓글 수: 0
채택된 답변
Image Analyst
2012년 4월 15일
Don't insert input arguments to your button callbacks. I think they expect to have (hObject, eventdata, handles) as the first three, and in that specific order. Perhaps you could try adding args to the end.
To share variables between callbacks, either get the value directly from the control with the get() function, where you pass in the known "tag" name of the control and ask for the 'value' property,
controlValue = get(handles.controlTag, 'Value');
or, if it's not a control, then see the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!