文档及代码程序如下
百度网盘。提取码2WTC
%% “PL_free.m”
function PL = PL_free(fc,dist,Gt,Gr)
%自由空间路径损耗模型
%% 输入
% fc : 载波频率[Hz]
% dist : 基站和修动台之间的图[m]
% Gt : 发射机天线增益
% Gr : 接收机天线增益
%输出
% PL : 路径损耗[dB]
lamda = 3e8/fc;
tmp = lamda./(4*pi*dist);
if nargin > 2,tmp = tmp*sqrt(Gt); end
if nargin > 3,tmp = tmp*sqrt(Gr); end
PL = -20*log10(tmp); %式(1.2)/(1.3)
%% "PL_logdist_or_norm.m"
function PL = PL_logdist_or_norm(fc,d,d0,n,sigma)%对数距离或对数阴影路径损耗模型
%% 输入
% fc : 载波频率[Hz]
% d : 基站和移动台之间的距离[m]
% d0 : 参考距离[m]
% n : 路径损耗指数
% sigma : 方差[dB]
%% 输出
% PL : 路径损耗[dB]
lamda = 3e8/fc;
PL = -20*log10(lamda/(4*pi*d0)) + 10*n*log10(d/d0); %式(1.4)
if nargin > 4
PL - PL + sigma*randn(size(d)); %式(1.5)
end
%% "plot_PL_general.m"
clear all;clf;clc;
fc = 1.5e9;
d0 = 100;
sigma = 3;
distance = [1:2:31].^2;
Gt = [1,1,0.5];
Gr = [1,0.5,0.5];
Exp = [2,3,6];
for k = 1:3
y_Free(k,:) = PL_free(fc,distance,Gt(k), Gr(k));
y_logdist(k,:) = PL_logdist_or_norm(fc,distance,d0,Exp(k));
y_lognorm(k,:) = PL_logdist_or_norm(fc,distance,d0,Exp(1),sigma);
end
figure('name','程序1.3','position',[0,40,1500,300]);
subplot(1,3,1);
semilogx(distance,y_Free(1,:),'k-o',distance,y_Free(2,:),'k-^' ,distance,y_Free(3,:),'k-s');
grid on;axis([1,1000,40,110]);
title(['Free PL-loss Model,f c=',num2str(fc/1e6),'MHz']);
xlabel('Distance[m]');ylabel('Path loss[dB]');
legend('G_t=1,G_r=1','G_t=1,G_r=0.5','G_t=0.5,G_r=0.5','location','b');
subplot(1,3,2);
semilogx(distance,y_logdist(1,:),'k-o' ,distance,y_logdist(2,:),'K-^' ,distance,y_logdist(3,:),'k-s');
grid on;axis([1 1000 40 110]);
title(['Log-distance Path-loss Model,f_c=',num2str(fc/1e6),'MHZ']);
xlabel('Distance[m]');ylabel('Path loss[dB]');
legend('n=2','n=3','n=6','location','b');
subplot(1,3,3);
semilogx(distance,y_lognorm(1,:),'k-o' ,distance,y_lognorm(2,:),'k-^' ,distance,y_lognorm(3,:),'k-s');
grid on;axis([1 1000 40 110]);
title(['Log-normal Path-loss Model,f_c=',num2str(fc/1e6),'MHz, ','\sigma=', num2str(sigma), 'dB']);
xlabel ('Distance[m]'); ylabel('Path loss[dB]');
legend('path 1','path 2','path 2','location','b');
%% Okumura/Hata模型
% "PL_Hata.m"
function PL=PL_Hata(fc,d,htx,hrx,Etype)
% Hata模型
% 输入
% fc : 载波频率[Hz]
% d : 基站与移动台之间的距离[m]
% htx : 发射机高度[m]
% hrx : 接收机高度[m]
% Etype: 环境类型['urban','suburban','open']
% 输出
% PL : 路径损耗[dB]
if nargin<5
Etype='URBAN';
end
fc = fc/(1e6);
if fc>=150&&fc<=200
C_Rx=8.29*(log10(1.54*hrx))^2-1.1;
elseif fc>200
C_Rx=3.2*(log10(11.75*hrx))^2-4.97;
else
C_Rx=0.8+(1.1*log10(fc)-0.7)*hrx-1.56*log10(fc);
end
PL=69.55+26.16*log10(fc)-13.82*log10(htx)-C_Rx...
+(44.9-6.55*log10(htx))*log10(d/1000);
Etype=upper(Etype);
if Etype(1)=='S'
PL=PL-2*(log10(fc/28))^2-5.4;
elseif Etype(1)=='O'
PL=PL+(18.33-4.78*log10(fc))*log10(fc)-40.97;
end
%% Okumura/Hata模型
% plot_PL_Hata.m
clear all;clf;
fc = 1.5e9;
htx = 30;
hrx = 2;
distance = [1:2:31].^2;
y_urban = PL_Hata(fc, distance, htx, hrx, 'urban');
y_suburban = PL_Hata(fc, distance, htx, hrx, 'suburban');
y_open = PL_Hata(fc, distance, htx, hrx, 'open');
semilogx(distance, y_urban, 'k-s', distance, y_suburban, 'k-o', distance,y_open, 'k-^');
title(['Hata PL model, f_c=', num2str(fc/1e6), 'MHz']);
xlabel('Distance[m]'), ylabel('Path loss[dB]')
legend('urban', 'suburban', 'open area','location','b');
grid on, axis([1 1000 40 110]);
%% IEEE 802.16d模型
%% "PL_IEEE80216d.m"
function PL=PL_IEEE80216d(fc,d,type,htx,hrx,corr_fact,mod)
% 输入:
% fc : 载波频率[Hz]
% d : 基站和移动台之间的距离[m]
% type : 可以选择'A','B'或'C'
% htx : 发射机高度[m]
% hrx : 接收机高度[m]
% corr_fact : 如果存在阴影,那么设置为'ATnT'或'Okumura'。否则,设置为'NO'
% mod : 设置为'mod'来得到修正的IEEE802.16d模型
% 输出:
% PL : 路径损耗[dB]
Mod='UNMOD';
if nargin>6
Mod=upper(mod);
end
if nargin==6&&corr_fact(1)=='m'
Mod='MOD';
corr_fact='NO';
elseif nargin<6
corr_fact='NO';
if nargin==5&&hrx(1)=='m'
Mod='MOD';
hrx=2;
elseif nargin<5
hrx=2;
if nargin==4&&htx(1)=='m'
Mod='MOD';
htx=30;
elseif nargin<4
htx=30;
if nargin==3&&type(1)=='m'
Mod='MOD';
type='A';
elseif nargin<3
type='A';
end
end
end
end
d0=100;
Type=upper(type);
if Type~='A'&&Type~='B'&&Type~='C'
disp('Error:The selected type is not supported');
return;
end
switch upper(corr_fact)
case 'ATNT'
PLf=6*log10(fc/2e9);
PLh=-10.8*log10(hrx/2);
case 'OKUMURA'
PLf=6*log10(fc/2e9);
if hrx<=3
PLh=-10*log10(hrx/3);
else
PLh=-20*log10(hrx/3);
end
case 'NO'
PLf=0;
PLh=0;
end
if Type=='A'
a=4.6;
b=0.0075;
c=12.6;
elseif Type=='B'
a=4;
b=0.0065;
c=17.1;
else
a=3.6;
b=0.005;
c=20;
end
lamda=3e8/fc;
gamma=a-b*htx+c/htx;
d0_pr=d0;
if Mod(1)=='M'
d0_pr=d0*10^-((PLf+PLh)/(10*gamma));
end
A=20*log10(4*pi*d0_pr/lamda)+PLf+PLh;
for k=1:length(d)
if d(k)>d0_pr
PL(k)=A+10*gamma*log10(d(k)/d0);
else
PL(k)=-10*log10((lamda/(4*pi*d(k)))^2);
end
end
%% IEEE 802.16d模型
% "plot_PL_IEEE80216d.m"
clear,clf,clc
fc=2e9;
htx=[30 30];
hrx=[2 10];
distance=[1:1000];
for k=1:2
y_IEEE16d(k,:)=PL_IEEE80216d(fc,distance,'A',htx(k),hrx(k),'atnt');
y_MIEEE16d(k,:)=PL_IEEE80216d(fc,distance,'A',htx(k),hrx(k),'atnt','mod');
end
subplot(121)
semilogx(distance,y_IEEE16d(1,:),'k:','linewidth',1.5),hold on
semilogx(distance,y_IEEE16d(2,:),'k-','linewidth',1.5),grid on
title(['IEEE 802.16d Path loss Models,fc=',num2str(fc/1e6),'MHz'])
axis([1 1000 10 150])
xlabel('Distance[m]'),ylabel('Pathloss[dB]')
legend('h_{Tx}=30m,h_{Rx}=2m','h_{Tx}=30m,h_{Rx}=10m','location','northwest')
subplot(122)
semilogx(distance,y_MIEEE16d(1,:),'k-','linewidth',1.5),hold on
semilogx(distance,y_MIEEE16d(2,:),'k-','linewidth',1.5),grid on
title(['Modified IEEE 802.16d Path loss Models,fc=',num2str(fc/1e6),'MHz'])
axis([1 1000 10 150])
xlabel('Distance[m]'),ylabel('Pathloss[dB]')
legend('h_{Tx}=30m,h_{Rx}=2m','h_{Tx}=30m,h_{Rx}=10m','location','northwest')
待更新……
待更新
待更新