Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
timer structure

Subject: timer structure

From: pink

Date: 11 Jun, 2011 22:21:04

Message: 1 of 2

I use the timer on a button, if I use multiple times often hangs, is there any error code structure?
my code

function rotatebutton_Callback(hObject, eventdata, handles)
MyTimer=timerfind('tag','MyTimer');
MyTimerStatus=get(MyTimer,'Running');
if strcmp(MyTimerStatus,'off')
start(MyTimer)
else
stop(MyTimer)
end

function RotImgFcn(a,b)
%this function does the rotation
camorbit(findall(0,'tag','MyAxes'),1,0,'data',[0 0 1]);

function axes1_CloseRequestFcn(hObject, eventdata, handles)
MyTimer=timerfind('tag','MyTimer');
MyTimerStatus=get(MyTimer,'Running');
if strcmp(MyTimerStatus,'on')
stop(MyTimer)
end
delete(timerfind('tag','MyTimer')); %delete our timer
delete(hObject);

% --- Executes on button press in plotbutton.
function plotbutton_Callback(hObject, eventdata, handles)
surf(peaks)
axis vis3d
MyTimer=timer('TimerFcn',@RotImgFcn,'BusyMode','queue','executionmode','fixedspacing','period',0.01);
%tag the timer and axes to have easy access to their handles
set(MyTimer,'tag','MyTimer')
set(handles.axes1,'tag','MyAxes')

% --- Executes on button press in xyview.
function button1_Callback(hObject, eventdata, handles)
MyTimer=timer('TimerFcn',@RotImgFcn,'BusyMode','queue','executionmode','fixedspacing','period',0.01);
%tag the timer and axes to have easy access to their handles
set(MyTimer,'tag','MyTimer')
set(handles.axes1,'tag','MyAxes')
view ([0 0])

function button1_Callback(hObject, eventdata, handles)
MyTimer=timer('TimerFcn',@RotImgFcn,'BusyMode','queue','executionmode','fixedspacing','period',0.01);
%tag the timer and axes to have easy access to their handles
set(MyTimer,'tag','MyTimer')
set(handles.axes1,'tag','MyAxes')
view ([90 0])

thanks

Subject: timer structure

From: pink

Date: 11 Jun, 2011 22:32:02

Message: 2 of 2

I use the timer on a button, if I use multiple times often hangs, is there any error code structure?
my code

function rotatebutton_Callback(hObject, eventdata, handles)
MyTimer=timerfind('tag','MyTimer');
MyTimerStatus=get(MyTimer,'Running');
if strcmp(MyTimerStatus,'off')
start(MyTimer)
else
stop(MyTimer)
end

function RotImgFcn(a,b)
%this function does the rotation
camorbit(findall(0,'tag','MyAxes'),1,0,'data',[0 0 1]);

function axes1_CloseRequestFcn(hObject, eventdata, handles)
MyTimer=timerfind('tag','MyTimer');
MyTimerStatus=get(MyTimer,'Running');
if strcmp(MyTimerStatus,'on')
stop(MyTimer)
end
delete(timerfind('tag','MyTimer')); %delete our timer
delete(hObject);

% --- Executes on button press in plotbutton.
function plotbutton_Callback(hObject, eventdata, handles)
surf(peaks)
axis vis3d
MyTimer=timer('TimerFcn',@RotImgFcn,'BusyMode','queue','executionmode','fixedspacing','period',0.01);
%tag the timer and axes to have easy access to their handles
set(MyTimer,'tag','MyTimer')
set(handles.axes1,'tag','MyAxes')

% --- Executes on button press in xyview.
function button1_Callback(hObject, eventdata, handles)
MyTimer=timer('TimerFcn',@RotImgFcn,'BusyMode','queue','executionmode','fixedspacing','period',0.01);
%tag the timer and axes to have easy access to their handles
set(MyTimer,'tag','MyTimer')
set(handles.axes1,'tag','MyAxes')
view ([0 0])

function button2_Callback(hObject, eventdata, handles)
MyTimer=timer('TimerFcn',@RotImgFcn,'BusyMode','queue','executionmode','fixedspacing','period',0.01);
%tag the timer and axes to have easy access to their handles
set(MyTimer,'tag','MyTimer')
set(handles.axes1,'tag','MyAxes')
view ([90 0])

thanks

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us