GUI edit text box values not getting updated

3 views (last 30 days)
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.

Accepted Answer

Jan
Jan on 2 Apr 2013
Edited: Jan on 2 Apr 2013
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')

More Answers (0)

Categories

Find more on Characters and Strings 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!