pass extra parameter to fsolve and get the error 'Not enough input arguments.'

1 次查看(过去 30 天)
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 个评论
John D'Errico
John D'Errico 2013-12-23
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by