Borrar filtros
Borrar filtros

Error using Timerfcn: too many input arguments

6 visualizaciones (últimos 30 días)
Umberto
Umberto el 3 de Abr. de 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.

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 3 de Abr. de 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

Más respuestas (0)

Categorías

Más información sobre Biological and Health Sciences en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by