⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 threesectorpathgain.m

📁 基于OFDM的无线宽带系统仿真It contains mainly two parts, i.e. link-level simulator and system-level simulator.
💻 M
字号:
% Three Sector path gain
function g = threeSectorpathGain(xym, xyb, fib, rombvec, gainconst, alpha, sigma, raa, lobevector, lognmap, mapvec, sps, ncluster,ncell_per_cluster,dmin)
% DESCRIPTION g = pathgain(xym, xyb, fib, rombvec, gainconst, alpha, ...
%                          sigma, raa, lobevector, lognmap, mapvec)
%  Caluculates the gain in dB between all mobiles and all bases. 
% INPUT
%  xym --        Mobile coordinates, given as a complex column vector.
%  xyb --        Base station coordinates, given as a complex row vector.
%  fib --        Base station antenna vector, given as a row vector. Points
%                in the antenna direction.
%  rombvec --    Two complex vectors spanning the rombic area containing cells.
%  gainconst --  Gain at 1 meter distance.
%  alpha --      Distance attenuation coefficient.
%  sigma --      Standard deviation for the lognormal fading in dB.
%  raa --        Down link correlation (typical 0.5). This parameter determines
%                the correlation for the lognormal fading on the links
%                between the base stations and one mobile.
%  lobevector -- Antenna gain for all directions, a column vector 
%	              with 360 rows, one for each degree. 
%  lognmap --    Lognormal map used to create lognormal fading.
%  mapvec --     Two complex vectors that will determine the size of lognmap.
%  sps --       Sectors Per Site
%  ncluster --  Number of clusters, actually, number of clusters is ncluster^2
% ncell_per_cluster ---
%               Number of cells per cluster , truely, number of BS
%               locations per cluster
% dmin  --   min distance between SB and MS(UE)
% OUTPUT
%  g --          Gain for all links in dB, given as a matrix 
%                one column for each base and one row for each mobil 
% TRY 
%  [lognmap, mapvec] = crelognmap([],[1 i]*10000,100);
%  g = pathgain(0,0,1000,[1 i]*10000,21,3.5,6,0.5,0,lognmap,mapvec)
%   Only one mobile and one base station.
%  xym = [rand(2)*[1;i]; rand(2)*[1;i]];
%  xyb = [1 i]*rand(2);
%  g = pathgain(xym,xyb,1000,[1 i]*10000,21,3.5,6,0.5,0,lognmap,mapvec)
%   Four mobiles and two base stations.
% SEE ALSO 
%  crelognmap, uselognmap

% by Magnus ALmgren 000510; TBS 050125
% modified by Suvra

if isempty(xym)
 g = zeros(0,size(xyb,2)); % Set to an empty matrix.
% break
 return
end

% % Wrap around in 9 fictive positions. 
% bv = -1:1;
r = 0;  
% if all(isfinite(rombvec)) % no rombvec, no wrap around
%  r = flatten_(mplus(rombvec(1)*bv.', rombvec(2)*bv),3);
% end
wad = mplus(xym, -xyb, r);
 
% distance gain
% Make sure that the used distance is not less than 10 units (uma 95 08
% 02). % both 1732 and 500 are same! for gainconst= -21 & alpha=3.76 OR
% gainconst= -27.5 & alpha=3.71
%gatt = gainconst - alpha * 10 * log10((max(dmin,abs(wad))));
gatt1 = -(39+20*log10(abs(wad)));
gatt2 = -(-39+67*log10(abs(wad)));
idx = abs(wad)<=45;
gatt = gatt1.*idx + gatt2.*(~idx);
% 3GPP LTE (e-utra model) as per 25.814 ,% on top of each other!!!
% gatt = -128.1 - 37.6*log10((max(36,abs(wad)))/1e3);


% 3GPP LTE as per the erricsson paper: between the one given by troels
% gatt = -35.3 - 37.6*log10((max(36,abs(wad))));

% Angle attenuation between direction to mobiles and cell main direction added.
gant=0; 
fib(fib==0)=1;       % Point omnidirectional antennas west
bangle = angle(mdiv(wad,fib));
gant = lobevector(wrapind(bangle*180/pi,360));
% gant(:,:,5) is the minimum ! can be used to check the angle calculations

% Select the position with highest gain of all wrap positions
g = max(gant+gatt,[],3);
clear gatt; % These may be big. 
clear gant;

% Lognormal fading with base station correlation added.
if sigma ~=0
 oseed = setseed(1); % Create a random base offset.
 maxdist = max(flatten_(abs(mplus(xyb,-xyb.')))); % max distance 
 xyboffs = irand(size(xyb))*maxdist*10; % scramble base pos
 setseed(oseed);
 base_local_shadow=uselognmap(repmat(xym,[1 size(g,2)]),lognmap,mapvec);
 
 % shadowing 100% sector correlation + random other cell correlation
%  if sps>1
     randomShadow=[];
     for lp_nclus = 1:ncluster.^2
         shadtmp=uselognmap(mplus(-xym,xyboffs(ncell_per_cluster*sps*(lp_nclus-1)+1:ncell_per_cluster*sps*(lp_nclus-1)+ncell_per_cluster)),lognmap,mapvec);
         shadtmp=repmat(shadtmp,[1 sps]);
         randomShadow=[randomShadow shadtmp];
     end
     
%  end
 g = g + sigma * (...
 sqrt(1-raa) * base_local_shadow + ...
 sqrt(raa)   * randomShadow);%;%uselognmap(repmat(xym,[1 size(g,2)]),lognmap,mapvec));%...


%  g = g + sigma * (...
%  (1-raa) * base_local_shadow + ...
%  (raa)   * randomShadow);%;%uselognmap(repmat(xym,[1 size(g,2)]),lognmap,mapvec));%...





% % The code otherwise
%    g = g + sigma * (...
%   sqrt(1-raa) * uselognmap(mplus(-xym,xyboffs),lognmap,mapvec) + ...
%   sqrt(raa)   * uselognmap(repmat(xym,[1 size(g,2)]),lognmap,mapvec)...
%   );

end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -