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
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 Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!