Not Enough Input Arguments in fsolve

10 visualizaciones (últimos 30 días)
Khoirunnisa' Irodatillah
Khoirunnisa' Irodatillah el 27 de Mzo. de 2019
Comentada: Khoirunnisa' Irodatillah el 27 de Mzo. de 2019
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;
>>

Respuesta aceptada

Catalytic
Catalytic el 27 de Mzo. de 2019
Editada: Catalytic el 27 de Mzo. de 2019
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 comentarios
Catalytic
Catalytic el 27 de Mzo. de 2019
As you can now see, fun() is supposed to contain only the code that computes f.
Khoirunnisa' Irodatillah
Khoirunnisa' Irodatillah el 27 de Mzo. de 2019
OH.. I see,, thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by