In order to cyclically change the text string on the push button, you need to determine what the current 'String' property value is, and set it to the other value.
Below is an example of a push button that switches the push button's String between ''Pause" and ''Resume" :
function Test_Button(hObject, eventdata, handles, varargin)
Fig = figure;
PushCtrl = uicontrol( Fig,'Style' ,'pushbutton',...
'String', 'Pause',...
'Position', [20 20 100 60],...
'Callback', @push_Callback);
handles = guihandles(Fig);
handles.strings = {'Pause';'Resume'};
guidata(Fig, handles);
function varargout = push_Callback(h, eventdata)
handles = guidata(h);
str = get(h,'String');
ind = find(strcmp(str,handles.strings));
if ind == 1
set(h,'String',handles.strings{2});
else
set(h,'String',handles.strings{1});
end
Best Answer