Borrar filtros
Borrar filtros

how to use function in fzero as a variable file

1 visualización (últimos 30 días)
David Pesetsky
David Pesetsky el 9 de Oct. de 2016
Comentada: David Pesetsky el 10 de Oct. de 2016
Hello,
There's a simple example of fzero here, that defines a function in a file called f.m: https://www.mathworks.com/help/matlab/ref/fzero.html
What I need, is that f.m to be a variable passed into the calling function, because it can be from any file (f.m, f1.m, etc). Matlab complains if i try to pass in f through arguments because it's already used as a function. Is there a trick to it?
Thanks so much,
Dave

Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de Oct. de 2016
Look at this other example instead:
fun = @f; % function
x0 = 2; % initial point
z = fzero(fun,x0)
and if you wanted f1.m then you would use
fun = @f1
  3 comentarios
Walter Roberson
Walter Roberson el 10 de Oct. de 2016
str2func
David Pesetsky
David Pesetsky el 10 de Oct. de 2016
I got that to work. Thank you.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Function Handles 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