"Not enough input arguments." error on TimerFcn
1 view (last 30 days)
Show older comments
Hi, i'm new to matlab and i'm trying to make that when click the button in GUI it will put some of 1 (5 to be exact)into random address of(1*16)matrix every sec for 5 sec by using timer here is my code
function start_Callback(hObject, eventdata, handles)
% hObject handle to start (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if true;
handles.level = 5;
handles.RDM = timer;
handles.RDM.Period = 1;
handles.RDM.ExecutionMode = 'fixedRate';
handles.RDM.TimerFcn = @rdmnew;
handles.RDM.TasksToExecute = 5;
handles.Btt = zeros(1,16);
for loop = 1:handles.level
x = randi(16,1);
handles.Btt(x)=1;
end
start(handles.RDM)
guidata(hObject,handles);
end
delete(handles.RDM);
function rdmnew(hObject, eventdata, handles)
for k=1:handles.level
x = randi(16,1);
handles.Btt(x)=1;
end
guidata(hObject,handles);
and it got the error
Error while evaluating TimerFcn for timer 'timer-1'
Not enough input arguments.
and i have no idea how to solve it
i would really appreciate any help
Thank you in advance.
0 Comments
Answers (1)
Walter Roberson
on 9 Jan 2014
Timers are not passed the "handles" structure unless you specially arrange it.
You could change
handles.RDM.TimerFcn = @rdmnew;
to
thisfig = ancestor(hObject, 'figure');
handles.RDM.TimerFcn = @(hObject, eventdata) rdmnew(hObject, eventdata, guidata(thisfig));
0 Comments
See Also
Categories
Find more on String in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!