GUI edit text box values not getting updated

Hi friends i am working with matlab gui. Problem is string values are not getting updated. please check the sample code below
if true
function pushbutton_Callback(hObject, eventdata, handles)
if strcmp(get(handles.pushbutton,'String'),'START')
set(handles.pushbutton,'String','STOP')
%some code
while(strcmp(get(handles.pushbutton,'String'),'STOP'))
disp('Entered while loop')
%some code
Input1=sscanf(InputTemp, '%d')
set(handles.Textbox1, 'String', Input1)
end
[ Control ] = Controller( Input1 ) %function that will give control signal %depending on input temperature
if(Control=='0001')
set(handles.Textbox2, 'String','some text' )
else
set(handles.Textbox2, 'String','some text1' )
end
%some code
end
else
set(handles.pushbutton,'String','START')
end
end
If i hit 'pushbutton' string "start" should be changed to "stop" but that is not happening. But if that is the case process should not enter while loop. But it is entering while loop and running every thing inside continuously as required(receiving values and sending desired values through serial port). Only problem i am getting in while loop is both edit text boxes 'Textbox1' and 'Textbox2' are not displaying required values. If i am terminating the process(Ctrl+C) then the final value of temperature and control strings are getting displayed. I am unable to find any error with the code. Please help me out with this.
Thanks in advance.

 채택된 답변

Jan
Jan 2013년 4월 2일
편집: Jan 2013년 4월 2일

0 개 추천

Give the button a chance to update by calling:
drawnow
Comparing strings by the == operator is prone to errors, so prefer STRCMP:
% if (Control=='0001') % Better:
if strcmp(Control, '0001')

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Identification에 대해 자세히 알아보기

질문:

2013년 4월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by