Why am I not able to find a solution using the bisection search i have implemented ?
1 view (last 30 days)
Show older comments
i am trying to implement bisection search. the code is given below with all values. But i cannot find solution or the root for this. my phi, lambda values are precalculated. even if i change my phi, lambda values it still won't work. i want my bisection search to work, please guide me
% bisection search
clc;
clear;
phi=[0.0002 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 - 0.0000i 0.0000 + 0.0000i -0.0000 + 0.0000i
0.0000 - 0.0000i -0.0000 - 0.0000i 0.0000 - 0.0000i ];
lambda=[0.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0602 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 - 0.0000i ];% 1.0e-03 *lambda
power=316.2278; % in watts
mu_array=[];
a=0.0001; %mu1 % chosen arbitrary
b=10; %mu2 %chosen arbitrary
TOL=0.0001; %tolerance value
max_itr=100; %max iterations
itr=0; %iterations
c=(a+b)/2;
result3=muh_function(phi,lambda,c,power);
if result3==0
mu_array=[mu_array c];
else
while abs(result3)>TOL && itr<=max_itr
result3=muh_function(phi,lambda,c,power);
result1=muh_function(phi,lambda,a,power);
result2=muh_function(phi,lambda,b,power);
if sign(result3)==sign(result1)
a=c;
b=b;
else
b=c;
a=a;
end
c=(a+b)/2;
itr=itr+1;
end
end
function result=muh_function(phi,lambda,muh,power)
M=2;
sum=0;
for m=1:M
sum=sum+(phi(m,m)/(lambda(m,m)+muh)^2);
end
result=sum-power;
end
0 Comments
Answers (0)
See Also
Categories
Find more on Beamforming 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!