Clear Filters
Clear Filters

I can't run this function -nonlinear equation system

2 views (last 30 days)
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 Comment
Alex Sha
Alex Sha on 31 Mar 2022
There are multi-solutions:
No. x1 x2
1 352.707085204498 -0.0552273002006459
2 -1.40777299574092 -1.68141237126893
3 352.707085204514 -5.57004739748473

Sign in to comment.

Answers (1)

Chunru
Chunru on 31 Mar 2022
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

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!