Filter löschen
Filter löschen

Error using Timerfcn: too many input arguments

6 Ansichten (letzte 30 Tage)
Umberto
Umberto am 3 Apr. 2013
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.

Akzeptierte Antwort

Sean de Wolski
Sean de Wolski am 3 Apr. 2013
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

Weitere Antworten (0)

Kategorien

Mehr zu Biological and Health Sciences finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by