clc
clear
close all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% some parameters %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
C0=3E8; % the speed of light
e=7-i*0.85; %the permeablity of the material considered at 1GHZ.
f=1000000000; %the frequency 1GHZ
d_antnne=linspace(0.5,5,200); %the interval of the distance between the points original and the antennes
t=1.5; %Instantaneous time
k=2*pi*f/C0; %the wave Number
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% initialization a space %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lengthy=20; %the length of space is 20m;
widthx=10; %the width of space is 10m;
highz=3; %the high of space is 30m;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% the coordinates of terminals %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x=4.5;
y=-9;
z=-2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% the coordinates of antennas %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A0=1; %the gain of signal from antenana1
B0=1; %the gain of signal from antenana2
C0=1; %the gain of signal from antenana3
D0=1; %the gain of signal from antenana4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% the phases of 4 signals %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
phase1=120;
phase2=180;
phase3=310;
phase4=0:1:359;
[d_antnne,phase4]=meshgrid(d_antnne,phase4); %set up relation between the distance of antnnes and phase4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% the coordinates of antennas %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
pos_antenna1x=0;
pos_antenna1y=-1*d_antnne;
pos_antenna1z=0;
pos_antenna2x=0;
pos_antenna2y=d_antnne;
pos_antenna2z=0;
pos_antenna3x=d_antnne;
pos_antenna3y=0;
pos_antenna3z=0;
pos_antenna4x=-1*d_antnne;
pos_antenna4y=0;
pos_antenna4z=0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculer the NLOS and LOS %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
L1 = distance3d_los(x,y,z,pos_antenna1x,pos_antenna1y,pos_antenna1z);
[L1_left,T1_left,L1_right,T1_right,L1_front,T1_front,L1_back,T1_back,L1_med,T1_med]=distance3d_nlos(widthx,lengthy,highz,x,y,z,pos_antenna1x,pos_antenna1y,pos_antenna1z,e);
L2 = distance3d_los(x,y,z,pos_antenna2x,pos_antenna2y,pos_antenna2z);
[L2_left,T2_left,L2_right,T2_right,L2_front,T2_front,L2_back,T2_back,L2_med,T2_med]=distance3d_nlos(widthx,lengthy,highz,x,y,z,pos_antenna2x,pos_antenna2y,pos_antenna2z,e);
L3 = distance3d_los(x,y,z,pos_antenna3x,pos_antenna3y,pos_antenna3z);
[L3_left,T3_left,L3_right,T3_right,L3_front,T3_front,L3_back,T3_back,L3_med,T3_med]=distance3d_nlos(widthx,lengthy,highz,x,y,z,pos_antenna3x,pos_antenna3y,pos_antenna3z,e);
L4 = distance3d_los(x,y,z,pos_antenna4x,pos_antenna4y,pos_antenna4z);
[L4_left,T4_left,L4_right,T4_right,L4_front,T4_front,L4_back,T4_back,L4_med,T4_med]=distance3d_nlos(widthx,lengthy,highz,x,y,z,pos_antenna4x,pos_antenna4y,pos_antenna4z,e);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% factor of attenuation %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a=1./L1; %factor of attenuation about antenna1
b=1./L2; %factor of attenuation about antenna2
c=1./L3; %factor of attenuation about antenna3
d=1./L4; %factor of attenuation about antenna4
a_left=1./L1_left;
a_right=1./L1_right;
a_front=1./L1_front;
a_back=1./L1_back;
a_med=1./L1_med;
b_left=1./L2_left;
b_right=1./L2_right;
b_front=1./L2_front;
b_back=1./L2_back;
b_med=1./L2_med;
c_left=1./L3_left;
c_right=1./L3_right;
c_front=1./L3_front;
c_back=1./L3_back;
c_med=1./L3_med;
d_left=1./L4_left;
d_right=1./L4_right;
d_front=1./L4_front;
d_back=1./L4_back;
d_med=1./L4_med;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% make the equetion of power %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
w_los=A0*a.*sin(2*pi*f*t-k*L1+phase1*pi/180)+B0*b.*sin(2*pi*f*t-k*L2+phase2*pi/180)+C0*c.*sin(2*pi*f*t-k*L3+phase3*pi/180)+D0*d.*sin(2*pi*f*t-k*L3+phase3*pi/180);
w_nlos1=a_left.*equation_reflection(T1_left,A0,f,phase1,t,L1_left)+a_right.*equation_reflection(T1_right,A0,f,phase1,t,L1_right)+a_front.*equation_reflection(T1_front,A0,f,phase1,t,L1_front)+a_back.*equation_reflection(T1_back,A0,f,phase1,t,L1_back)+a_med.*equation_reflection(T1_med,A0,f,phase1,t,L1_med);
w_nlos2=b_left.*equation_reflection(T2_left,B0,f,phase2,t,L2_left)+b_right.*equation_reflection(T2_right,B0,f,phase2,t,L2_right)+b_front.*equation_reflection(T2_front,B0,f,phase2,t,L2_front)+b_back.*equation_reflection(T2_back,B0,f,phase2,t,L2_back)+b_med.*equation_reflection(T2_med,B0,f,phase2,t,L2_med);
w_nlos3=c_left.*equation_reflection(T3_left,C0,f,phase3,t,L3_left)+c_right.*equation_reflection(T3_right,C0,f,phase3,t,L3_right)+c_front.*equation_reflection(T3_front,C0,f,phase3,t,L3_front)+c_back.*equation_reflection(T3_back,C0,f,phase3,t,L3_back)+c_med.*equation_reflection(T3_med,C0,f,phase3,t,L3_med);
w_nlos4=d_left.*equation_reflection(T4_left,D0,f,phase4,t,L4_left)+d_right.*equation_reflection(T4_right,D0,f,phase4,t,L4_right)+d_front.*equation_reflection(T4_front,D0,f,phase4,t,L4_front)+d_back.*equation_reflection(T4_back,D0,f,phase4,t,L4_back)+d_med.*equation_reflection(T4_med,D0,f,phase4,t,L4_med);
w=20*log10(abs(w_los+w_nlos1+w_nlos2+w_nlos3+w_nlos4)/(A0+B0+C0+D0));
figure(1);
mesh(d_antnne,phase4,w);
xlabel('Distance of antennas(m)');
ylabel('Phase4(��)');
zlabel('power W(dB)');
figure(2);
plot(phase4,w);
xlabel('Phase4(��)');
ylabel('power W(dB)');
figure(3);
plot(d_antnne,w);
xlabel('Distance of antennas(m)');
ylabel('power W(dB)');
评论0