I have a question about matlab timer object. I have a button in my gui that creates a timer and every period of 0.1 i want to call my function.
function playBtn_Callback(hObject, eventdata, handles)
global pl;
global c;
global g;
global t;
global myData;
if isplaying(pl)
pause(pl);
set(handles.playBtn, 'string', 'Play');
else
resume(pl);
set(handles.playBtn, 'string', 'Pause');
end
myData=guidata(handles.timertext);
c=get(pl, 'CurrentSample')
g=get(pl, 'TotalSample')
a = timer;
set(a, 'ExecutionMode', 'FixedRate');
set(a, 'TimerFcn', 'myFunction', 'Period', 0.1);
start(a);
function t = myFunction()
global mydata;
global pl;
global sf;
global mySong;
c=get(pl, 'CurrentSample')
set(mydata.timertext, 'String', c/sf);
sf is the frequency of my song.
The error i get is this:
Error while evaluating TimerFcn for timer 'timer-26'
Undefined function or variable 'myFunction'.