Effacer les filtres
Effacer les filtres

Error using Timerfcn: too many input arguments

6 vues (au cours des 30 derniers jours)
Umberto
Umberto le 3 Avr 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.

Réponse acceptée

Sean de Wolski
Sean de Wolski le 3 Avr 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
  1 commentaire
Umberto
Umberto le 3 Avr 2013
Thanks Sean, the problem is solved

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Biological and Health Sciences dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by