为计时器评估 TimerFcn 时出错。输入参数太多。软件
Error while evaluating TimerFcn for timer.. Too many input arguments. MATLAB
MatLab 应用程序设计器中的计时器问题。
它 return 一个错误:“为定时器评估 TimerFcn 时出错。输入参数太多”
我的代码:
app.t.TimerFcn = @app.timerFunction;
function timerFunction(app, ~, ~)
%something
end
我一直在寻找解决方案。我也试过这个:
app.t.TimerFcn = @(app, ~, ~)app.timerFunction
timerFunction(app, ~, ~)
app.t.TimerFcn = @(~,~)app.timerFunction
timerFunction(app)
如有任何帮助,我们将不胜感激。
您可以只使用 varargin
而不必担心事件抛出的输入参数的数量,即
function timerFunction( app, varargin )
% stuff
end
通过查看 varargin
.
的内容,这也将帮助您调试并查看 MATLAB 实际上试图传递多少输入
与您的其他尝试类似,您也可以在函数句柄中使用 varargin
,尽管这不允许进行相同的调试
app.t.TimerFcn = @(varargin) app.timerFunction;
找到的解是:
回调函数:
function timerFunction(app)
% stuff
end
定时器设置
app.t.TimerFcn = @(x,y)timerFunction(app);
有同样的问题,只是想让你知道这个错误可能有点误导。
就我而言,我通过计时器调用了一个函数,并且在该回调函数中进行了正常的函数调用:
T = timer('TimerFcn', @(~,~) this.callback, 'StartDelay', waitTime);
...
function callback(this)
...
this.doStuff(x,y);
end
function doStuff(x, y)
...
end
当然应该是:
function doStuff(this, x, y)
...
end
所以这个问题与定时器没有任何关系,而只是定时器回调函数执行的其他部分的错误。
MatLab 应用程序设计器中的计时器问题。 它 return 一个错误:“为定时器评估 TimerFcn 时出错。输入参数太多”
我的代码:
app.t.TimerFcn = @app.timerFunction;
function timerFunction(app, ~, ~)
%something
end
我一直在寻找解决方案。我也试过这个:
app.t.TimerFcn = @(app, ~, ~)app.timerFunction
timerFunction(app, ~, ~)
app.t.TimerFcn = @(~,~)app.timerFunction
timerFunction(app)
如有任何帮助,我们将不胜感激。
您可以只使用 varargin
而不必担心事件抛出的输入参数的数量,即
function timerFunction( app, varargin )
% stuff
end
通过查看 varargin
.
与您的其他尝试类似,您也可以在函数句柄中使用 varargin
,尽管这不允许进行相同的调试
app.t.TimerFcn = @(varargin) app.timerFunction;
找到的解是:
回调函数:
function timerFunction(app)
% stuff
end
定时器设置
app.t.TimerFcn = @(x,y)timerFunction(app);
有同样的问题,只是想让你知道这个错误可能有点误导。 就我而言,我通过计时器调用了一个函数,并且在该回调函数中进行了正常的函数调用:
T = timer('TimerFcn', @(~,~) this.callback, 'StartDelay', waitTime);
...
function callback(this)
...
this.doStuff(x,y);
end
function doStuff(x, y)
...
end
当然应该是:
function doStuff(this, x, y)
...
end
所以这个问题与定时器没有任何关系,而只是定时器回调函数执行的其他部分的错误。