pass extra parameter to fsolve and get the error 'Not enough input arguments.'
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
My code is quite simple as follows:
function y = parameterfun(x,a) y=-0.146027117126212*(x^3)+0.274370523899887*(x^2)+0.745211649356837*x+0.124882188460015-0.1*a; a = 4; f = @(x)parameterfun(x,a); s=fsolve(f,0.5)
I think it is OK but it keeps telling me the error, I really do not know how to deal it, I'll appreciate any help, thank you!
1 commentaire
John D'Errico
le 23 Déc 2013
First of all, learn to edit your question to format the text to be readable! This is trivial to do, so why not make your question readable?
Next, it appears that you are defining a function parameterfun, as an m-file. Why bother, since you are using a function handle anyway!
Next, you say it keeps giving you an error. WHAT ERROR WAS IT? Is it really necessary for us to guess what you are doing wrong? MATLAB returns an error. I'm pretty sure the error text will be useful to somebody, else why would it have done so?
Finally, why are you using fsolve to solve a one variable problem? Use fzero. It will be more efficient, especially if you can provide a bracket around the solution.
Réponses (0)
Voir également
Catégories
En savoir plus sur Startup and Shutdown 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!