MATLAB: Using a timer in GUI

guitimer

Hi, I have a GUI to manage UART communication. I want to use a timer as follows: if i haven't got the answer for what i requested, in 4ms time ,then re-send the request (for example).
I tried several timer configuration and for each i get an error message:"error while evaluating timerfcn for timer 'timer-x' , where x is keep changing.
i tried: in openingFcn:
handles.timer1 - timer('executionmode',fixedrate','period',0.005,'timerfcn',@(src,event)NameOfFunc(src,event,handles));
in the desierd callback :
start(handles.timer1)
in the function
function NameOfFunc(src,event,handles)
DO SOMETHING
end
i get error (this time) error while evaluating timerfcn for timer 'timer-6' i also tried defining the timer as a global parameter

Best Answer

function NameOfFun()
do something
end
Needs to take in the two inputs that come by default, src, evt.
function NameOfFun(src,evt)
do something
end
If you also want to pass in handles, like in your original, it needs to take in three inputs.