Not Enough Input Arguments in fsolve
조회 수: 23 (최근 30일)
이전 댓글 표시
Khoirunnisa' Irodatillah
2019년 3월 27일
댓글: Khoirunnisa' Irodatillah
2019년 3월 27일
please help to solve and explain why
function f = fun(x)
f(1) = (x(1)-4)^2 +(x(2)-4)^2 - 5;
f(2) = x(1)^2 + x(2)^2 - 16;
options = optimset('display','off')
x = fsolve(@fun,[2 3.5],options)
X = x(1)
Y = x(2)
>> fun()
Not enough input arguments.
Error in fun (line 2)
f(1) = (x(1)-4)^2 +(x(2)-4)^2 - 5;
>>
댓글 수: 0
채택된 답변
Catalytic
2019년 3월 27일
편집: Catalytic
2019년 3월 27일
function myProblem
options = optimset('display','off')
x = fsolve(@fun,[2 3.5],options)
X = x(1)
Y = x(2)
function f = fun(x)
f(1) = (x(1)-4)^2 +(x(2)-4)^2 - 5;
f(2) = x(1)^2 + x(2)^2 - 16;
end
end
Running gives the following result
>> myProblem
x =
1.8058 3.5692
X =
1.8058
Y =
3.5692
댓글 수: 3
Catalytic
2019년 3월 27일
As you can now see, fun() is supposed to contain only the code that computes f.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!