When you use a string to designate a function in a callback, then the string is eval()'d in a context equivalent to the base workspace, outside of any hierarchy. Only functions that are built-in or which have .m on the path can be accessed that way.
You should switch to using a function handle. Also, you need to make an adjustment for the fact that you are not expecting the standard parameters in your callback
handles.t = timer('BusyMode', 'queue', 'ExecutionMode',...
'fixedRate', 'Period', 4.0);
set(handles.t, 'TimerFcn', @(hObject, event) funkcija(event, handles));
Note that the handles variable that will be passed in to the callback will contain exactly whatever the handles structure contained at the time the anonymous function was created. The reason for splitting the assignment of handles.t and the setting of TimerFcn is that splitting it allows the timer handle itself to be recorded in the handles structure before that version of the structure is "frozen" for the purposes of the anonymous function.
If you want the current version of the handles object to be passed in to the function at the time the timer is fired, then the easiest route is to pass in information that allows you to figure out where the handle structure is. For example, you could use
handles.t = timer('BusyMode', 'queue', 'ExecutionMode',...
'fixedRate', 'Period', 4.0, 'TimerFcn', @funkcija);
with
function funkcija(hObject, EventData)
handles = guidata(hObject);
a = 1;
Best Answer