0

Can someone please explain how the function handle in this code works! Currently, the code is not jumping to the function and I'm trying to fix it. And can You please explain, how can I write the same code without using the function handle. This code is written for a Matlab GUI.

%...
handles.Data.Audio.TimerFcn={@TimerFcn, handles};
%...
function TimerFcn(audio,~,handles)
set(handles.Graphics.Line(2,handles.AudioNum),'XData',handles.Data.TS.Time((handle.Data.k+1)*handles.Data.fs+audio.CurrentSample*[1,1]));
set(handles.Graphics.Line(2,handles.AudioNum),'Color' , 'y');
guidata(handles.Fig,handles);

So the code is using the function handle for "TimerFcn" function, and I don't really understand how this works. Therefore I can't fix the bug.

Hoki
  • 11,637
  • 1
  • 24
  • 43
  • 1
    The function seems to be called from a `timer` ... You have to look at the properties of the `timer` itself to know if it calls the function never ... once ... or repeatedly. May be the `timer` is defined but never started ? – Hoki Feb 25 '20 at 09:20

1 Answers1

0

handles is not a function but rather a struct that stores information about the elements in your MATLAB GUI.

The rest of the code should help to solve your problem. What I can understand with the code you posted is that you are assigning function TimerFcn to the object in Data.Audio. So, if the function TimerFcn is not reached is because the object in charge of this function is not managing to run it, e.g. if it is a timer that has to wait X seconds before run this function, maybe it is not correctly set (or may be the waiting time is too high).

I hope I help you to understand the problem.

R2pro
  • 113
  • 1
  • 8