possitive solution for set of three nonlinear eqations where t_1 t_2 and pi_2 are varaibles

조회 수: 1 (최근 30일)
Hi guys,
I have provided a code to solve a set of nonlinear equation where t_1, t_2 and Pi_2 are variables. We know all the variable should be positive.
for my case, I consider
Inputs Parameters
K = 4
K = 4
N = 1
N = 1
P_max = 2
P_max = 2
T = 2
T = 2
Noise_Prdb = -100
Noise_Prdb = -100
a= 1e-21
a = 1.0000e-21
BW = 10
BW = 10
epsilon = 0.0001
epsilon = 1.0000e-04
For different values of T, my code works but the solution is wrong becuase it gives me a similar values for t_1 which is impossible.
Could you please help me in this regard or give me an alternative to solve this set of equations.
Thank you inadvance
for q = 1:length(P_max)
for r = 1:length(T)
Minimum1 = 0;
P_3 = P_max(q);
R_3 = BW*log2(1+(P_3*h_worst^2)/(BW*Noise_Pr));
t_3 = L3/R_3;
t_1 = 0.0001;
OP_Point = zeros(6,K);
while t_1<T(r)-t_3
Sum = 0;
P_2 = zeros(1,K+1);
for i = K:-1:1
Sum = Sum+P_2(1,i+1)*h(i);
t_2 = T(r)-t_1-t_3;
P_2(1,i) = (2^(L2/(t_2*BW))-1)*(Sum+(BW*Noise_Pr))/(h(i)^2);
if P_2(1,i)>0 && abs(P_max(q)*h(i)*t_1^3-P_2(1,i)*t_2*t_1^2-a*L1^3)<epsilon
OP_Point(1,i) = t_1; OP_Point(2,i) = t_1; OP_Point(3,i) = t_2;
OP_Point(4,i) = t_3; OP_Point(5,i) = P_2(1,i); OP_Point(6,i) = P_3;
else
t_1 = t_1 + 0.0001;
break
end
end
if nnz(OP_Point) == 6*K
break
end
end
end
end
Unrecognized function or variable 'h_worst'.
  댓글 수: 4
Matt J
Matt J 2022년 5월 17일
편집: Matt J 2022년 5월 17일
Your code is hard to unpack because you have included all kinds of extra lines which handle data set-up and display, and which have nothing to do with the solving the actual equations. You should show us just the part of your code dedicated to solving the equations. Additonal variables needed to run that part of the code can be attached in a .mat file.
Hossein Alishahi
Hossein Alishahi 2022년 5월 17일
편집: Hossein Alishahi 2022년 5월 17일
Thank you for your comment.
Do you have any suggestion to solve this set of equations?
Here is the main part of code for solving th equations
for q = 1:length(P_max)
for r = 1:length(T)
P_3 = P_max(q);
R_3 = BW*log2(1+(P_3*h_worst^2)/(BW*Noise_Pr));
t_3 = L3/R_3;
t_1 = 0.0001;
while t_1<T(r)-t_3
Sum = 0;
P_2 = zeros(1,K+1);
for i = K:-1:1
Sum = Sum+P_2(1,i+1)*h(i);
t_2 = T(r)-t_1-t_3;
t_11(i) = t_1;
P_2(1,i) = (2^(L2/(t_2*BW))-1)*(Sum+(BW*Noise_Pr));
if P_2(1,i)>0 && abs(P_max(q)*h(i)*t_11(i)^2*t_1-P_2(1,i)*t_11(i)^2-a*L1^3)<epsilon
OP_Point1(1,i) = t_1; OP_Point1(2,i) = t_11(i); OP_Point1(3,i) = t_2;
OP_Point1(4,i) = t_3; OP_Point1(5,i) = P_2(1,i); OP_Point1(6,i) = P_3;
else
t_1 = t_1+0.0001;
break
end
end
if nnz(OP_Point1) == 6*K
break
end
end
end
end

댓글을 달려면 로그인하십시오.

답변 (1개)

Torsten
Torsten 2022년 5월 17일
Solve the first equation for t_i2.
Solve the second equation for P_i2 and insert the expression for t_i2 from the first equation.
Both t_i2 and P_i2 now should only depend on t1.
Insert the expressions for both in the third equation.
I think you arrive at
Li2/(T-Li3/Ri3-t1) - log2(1 + (Pmax*hi*t1^3-a*Li1^3)*hi^2/(t1^2*(T-Li3/Ri3-t1))/(sum_{m>i}...)) = 0
This is one equation in one unknown.
Use fzero to solve for t1.
Insert t1 in the expressions for t_i2 and P_i2 to get these variables, too.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by