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에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!