Doubt regarding the fzero command.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi guys,
What does it mean when we write in a code P0 = fzero (@somefunction, [1, 25]). Does it mean search for an answer in the interval from 1 to 25 ? I usually set one value in which fzero start its search for the solution.
That`s the actual line that`s puzzling me
P0=fzero(@(P0) estimateSurfacePressure(P0,false,extPar), [1 25]);
The last thing is estimateSurfacePressure is a .m file the way fzero goes in this file is pretty weird for me. What does @(P0) mean? It looks somewhat like those function we create like this y = @(x) [x^2] is there something to do with it?
Thank you very much for helping.
0 Commenti
Risposta accettata
José-Luis
il 5 Giu 2014
Modificato: José-Luis
il 5 Giu 2014
It means that the function estimateSurfacePressure() is in the path and will be evaluated for different values of PO until one yielding zero value has been found.
It also means that estimateSurfacePressure() returns a scalar.
2 Commenti
José-Luis
il 5 Giu 2014
Modificato: José-Luis
il 5 Giu 2014
Yes, it will look for an answer in the [1 25] interval.
fzero() takes a scalar-valued function handle as first argument. estimateSurfacePressure() takes three arguments but the author of the code only wanted to find the roots when one of them varies. Therefore he uses a function handle that allows him to let only P0 vary.
With the @ you are creating an anonymous function, that takes only one argument: P0 and is then passed to fzero().
Please read the documentation of function handles for further information.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Startup and Shutdown in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!