Error using trustnleqn (line 28)

5 views (last 30 days)
Amirul Hezry
Amirul Hezry on 24 Feb 2020
Commented: Amirul Hezry on 25 Feb 2020
Hello everyone,
I'm trying to solve non linear equations system using fsolve. I'm beginner in matlab I just have no idea what's going on with my program when I tried to run it, there's an error message in the command window:
function F = BEB(x)
n = 50; %number of stations
F(1) = x(1) - (2) / (1-x(2))*((1+x(2))+ 16*(1+2*x(2))+ ((x(2)^3)/(1-2*x(2)))*((x(2)/1-x(2))-((x(2)/1-x(2))^6)/((x(2)/1-x(2))^2))*((64*x(2)^3)/1-3*x(2))*(2*(x(2)/1-x(2))-((2*(x(2)/1-x(2)))^6))/(2*(x(2)/1-x(2))^2));
F(2) = (1-x(1))^n + x(2) -1;
i run it:
fun = @BEB
x0 = [0 0]
x = fsolve (fun, x0)

Answers (1)

Walter Roberson
Walter Roberson on 24 Feb 2020
Part of your expression is
((x(2)/1-x(2))^6)/((x(2)/1-x(2))^2))
The right hand side of that is (x(2)/1 - x(2))^2 which is (x(2) - x(2))^2 which is 0^0 which is 0. You are dividing by that zero. Division by 0 is going to get you one of -inf, +inf, or nan, depending what the numerator works out as. Your numerator happens to work out as 0 because it also has the X(2)/1-x(2) basic unit.
Therefore your expression always includes 0 / 0 which is NaN, so BEB always returns NaN as the first value. Most routines will give up when they see a nan result.
  4 Comments
Amirul Hezry
Amirul Hezry on 25 Feb 2020
Assume X(1) = tau (packet transmission probability X(2) = P (probability of collision

Sign in to comment.

Categories

Find more on Programming 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!