Hello,
I have a GUI with 2 edit text and 1 pushbutton. What I would like to do is to set a value to 1 edittext (say edit2) and within a while loop, increment the value of the other edittext (say edit1). For example: edit2 is set to value = 2, and when edit1's value = 2, then display('ok')
Here is the code:
*function edit2_Callback(hObject, eventdata, handles)* % hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
handles.edit2 = get(hObject, 'String'); display(handles.edit2);*function pushbutton1_Callback(hObject, eventdata, handles)* % hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
handles = guidata(hObject); handles.burst = 0; while handles.burst ~= 10 handles.burst = handles.burst+ 1; pause(1); set(handles.edit1, 'String', sprintf('%d', handles.burst)); if strcmp(handles.edit1, handles.edit2) display('ok'); end % Update handles structure
guidata(hObject, handles); end
Best Answer