필터 지우기
필터 지우기

Error using Timerfcn: too many input arguments

조회 수: 6 (최근 30일)
Umberto
Umberto 2013년 4월 3일
Hello. I created this timer
t = timer('Period', delay, 'TimerFcn', calculate(V, g, n, Vmin, Vmax));
which calls a function named "calculate"
function calculate
...
end
What's wrong with this code? Matlab returns this error message: ??? Error using ==> simulation>calculate Too many input arguments.

채택된 답변

Sean de Wolski
Sean de Wolski 2013년 4월 3일
The Timerfcn is automatically passed two inputs, a handle to the timer and some event data.
In order to do what you have above (where you don't need either of the two given inputs) would be to use an anonymous function to absorb them:
t = timer('Period', delay, 'TimerFcn', @(~,~)calculate(V, g, n, Vmin, Vmax));
The '~' just ignores the input.
Also, your function calculate looks like it doesn't take any inputs. It would need to accept at least 5:
function calculate(V, g, n, Vmin, Vmax)
...
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Biological and Health Sciences에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by