What is wrong with my timer function? (Too many input arguments?)
Hi all, amateur Matlab user here, so I apologize if this question seems silly.
I have a constantly changing variable called ‘a’, and I want to create an array called ‘asamplevalues’ that contains the value of ‘a’ sampled at 4 second intervals.
Here is the part of the script that describes and calls up the timer function:
handles.samplingtimer = timer(‘Period’, 4.0, ‘ExecutionMode’,’fixedRate’,’TasksToExecute’, 10e6);
handles.samplingtimer.TimerFcn = { @samplinga, handles };
start (handles.samplingtimer);
Here is the timer function itself:
function [asamplevalues] = samplinga(a)
if isempty(asamplevalues) == 1
asamplevalues = [100];
else asamplevalues = [asamplevalues, a];
end
end
When the program gets to the timer function I get this error message:
??? Error while evaluating TimerFcn for timer ‘timer-3’
Too many input arguments.
Any help or suggestions are greatly appreciated! Thanks!Hi all, amateur Matlab user here, so I apologize if this question seems silly.
I have a constantly changing variable called ‘a’, and I want to create an array called ‘asamplevalues’ that contains the value of ‘a’ sampled at 4 second intervals.
Here is the part of the script that describes and calls up the timer function:
handles.samplingtimer = timer(‘Period’, 4.0, ‘ExecutionMode’,’fixedRate’,’TasksToExecute’, 10e6);
handles.samplingtimer.TimerFcn = { @samplinga, handles };
start (handles.samplingtimer);
Here is the timer function itself:
function [asamplevalues] = samplinga(a)
if isempty(asamplevalues) == 1
asamplevalues = [100];
else asamplevalues = [asamplevalues, a];
end
end
When the program gets to the timer function I get this error message:
??? Error while evaluating TimerFcn for timer ‘timer-3’
Too many input arguments.
Any help or suggestions are greatly appreciated! Thanks! Hi all, amateur Matlab user here, so I apologize if this question seems silly.
I have a constantly changing variable called ‘a’, and I want to create an array called ‘asamplevalues’ that contains the value of ‘a’ sampled at 4 second intervals.
Here is the part of the script that describes and calls up the timer function:
handles.samplingtimer = timer(‘Period’, 4.0, ‘ExecutionMode’,’fixedRate’,’TasksToExecute’, 10e6);
handles.samplingtimer.TimerFcn = { @samplinga, handles };
start (handles.samplingtimer);
Here is the timer function itself:
function [asamplevalues] = samplinga(a)
if isempty(asamplevalues) == 1
asamplevalues = [100];
else asamplevalues = [asamplevalues, a];
end
end
When the program gets to the timer function I get this error message:
??? Error while evaluating TimerFcn for timer ‘timer-3’
Too many input arguments.
Any help or suggestions are greatly appreciated! Thanks! sampling, timer, too many input arguments MATLAB Answers — New Questions