I can't run this function -nonlinear equation system

Hello!
My code is:
function F = root(x)
F(1) = ((1/((1/(32/(x(1)*60)))+(1/(1/((5.67E-08*60*(x(1)^2+353^2)*(x(1)+353))/(1/0.035+(60/57.7*(1/0.035-1))))))))*(x(1)-20) - (8/(0.082*57.7))*(353-x(1)));
F(2) = ((1/((1/(32/(x(2)*60)))+(1/(1/((5.67E-08*60*(x(1)^2+353^2)*(x(1)+353))/(1/0.035+(60/57.7*(1/0.035-1)))))))) + (8/(0.082*57.7)))*(353-x(1)) - ((1/((1/(32/(x(2)*57.7))))+(1/(1/((5.67E-08*57.7*(x(1)^2+353^2)*(x(1)+353))/(1/0.035+(60/57.7*(1/0.035-1))))))))*(x(1)-20);
end
I am trying to solve this equation and it gives me the following error:
fun = @root;
x0 = [0,0];
x = fsolve(fun,x0)
Error using fsolve
Objective function is returning undefined values at initial point. FSOLVE cannot continue.

1 个评论

There are multi-solutions:
No. x1 x2
1 352.707085204498 -0.0552273002006459
2 -1.40777299574092 -1.68141237126893
3 352.707085204514 -5.57004739748473

请先登录,再进行评论。

回答(1 个)

fun = @root;
% Your function is not defined at [0,0]
root([0 0])
ans = 1×2
-604.5139 Inf
% Try a different initial points
x0 = [0.1,0.1];
x = fsolve(fun, x0)
Solver stopped prematurely. fsolve stopped because it exceeded the function evaluation limit, options.MaxFunctionEvaluations = 2.000000e+02.
x = 1×2
1.0e+06 * 0.0001 -2.8223
% Suggest to check the function definition to see if the problem is well
% defined
function F = root(x)
F(1) = ((1/((1/(32/(x(1)*60)))+(1/(1/((5.67E-08*60*(x(1)^2+353^2)*(x(1)+353))/(1/0.035+(60/57.7*(1/0.035-1))))))))*(x(1)-20) - (8/(0.082*57.7))*(353-x(1)));
F(2) = ((1/((1/(32/(x(2)*60)))+(1/(1/((5.67E-08*60*(x(1)^2+353^2)*(x(1)+353))/(1/0.035+(60/57.7*(1/0.035-1)))))))) + (8/(0.082*57.7)))*(353-x(1)) - ((1/((1/(32/(x(2)*57.7))))+(1/(1/((5.67E-08*57.7*(x(1)^2+353^2)*(x(1)+353))/(1/0.035+(60/57.7*(1/0.035-1))))))))*(x(1)-20);
end

类别

帮助中心File Exchange 中查找有关 Systems of Nonlinear Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by