Demo entry 6763246

1

   

Submitted by joy on Oct 21, 2018 at 10:32
Language: Matlab. Code size: 2.8 kB.

% clear all data
clc
clear
close all

tic
%% cell setting
R = 500;
L = 2.*R./2.*sqrt(3);
pt1 = 46;
f1 = 2000;
f2 = 900;
Dhb1 = 30;
Dhb2 = 20;

% coordinates of macro base stations
x_y = [0 0;0 L;1.5*R L/2; 1.5*R -L/2;0 -L;-1.5*R -L/2;-1.5*R L/2;...
       0 2*L;1.5*R 1.5*L;3*R L;3*R 0;3*R -L;1.5*R -1.5*L;0 -2*L;...
       -1.5*R -1.5*L;-3*R -L;-3*R 0;-3*R L;-1.5*R 1.5*L];

for i = 1:length(x_y)  
% boundaries of base stations
K1 = 0;B1 = x_y(i,2)+ L/2;
K2 = -L/R;B2 = x_y(i,2)+L/R*(R+x_y(i,1));
K3 = L/R;B3 = x_y(i,2)-L/R*(R+x_y(i,1));
K4 = 0;B4 = x_y(i,2)- L/2;
K5 = -L/R;B5 = x_y(i,2)-L+L/R*x_y(i,1);
K6 = L/R;B6 = x_y(i,2)+L-L/R*x_y(i,1);

x = [round(x_y(i,1)-R):1:round(x_y(i,1)+R)];
y = [round(x_y(i,2)-L/2):1:round(x_y(i,2)+L/2)];
X=[];Y=[];D=[];PR=[];PI=[];SIR=[];
for m=1:length(y)
    X_row=[];
    Y_row=[];
    d_row=[];
    pr_row = [];
    pi_row =[];
    sir_row = [];
    for n=1:length(x)
        if (y(m)<=K1*x(n)+B1) & (y(m)<=K2*x(n)+B2) ...
            & (y(m)>=K4*x(n)+B4) & (y(m)>=K3*x(n)+B3) ...
            & (y(m)<=K6*x(n)+B6) & (y(m)>=K5*x(n)+B5)
        d_total=sqrt((x(n)-x_y(:,1)).^2 +(y(m)-x_y(:,2)).^2);
        pr_total = pt1 - (40*(1-4*10^-3*Dhb1)*log10(d_total./1000)-18*log10(Dhb1)+21*log10(f1)+80);
        pr=pr_total(i);
        d=d_total(i);
        pi_mw= sum(10.^((pr_total)./ 10))-10.^((pr)./ 10);
        pi = 10.*(log10(pi_mw)); %dB
        sir = pr-pi;
        
        X_row=[X_row x(n)];
        Y_row=[Y_row y(m)];
        d_row=[d_row d];
        pr_row=[pr_row pr];
        pi_row=[pi_row pi];
        sir_row=[sir_row sir];
        else
        X_row=[X_row NaN];
        Y_row=[Y_row NaN];
        d_row=[d_row NaN];
        pr_row=[pr_row NaN];
        pi_row=[pi_row NaN];
        sir_row=[sir_row NaN];
        end
        
    end
    X=[X;X_row];
    Y=[Y;Y_row];
    D=[D;d_row];
    PR=[PR;pr_row];
    PI=[PI;pi_row];
    SIR=[SIR;sir_row];
end

% plot(X,Y,'.')
% xlabel('Horizontal axis /m');
% ylabel('Vertical axis /m');
% title('Theoretical coverage area');
% hold on

% h1=imagesc(x,y,D)
% set(h1, 'alphadata', ~isnan(D))
% colorbar
% xlabel('Horizontal axis /m');
% ylabel('Vertical axis/m');
% title('Distances to the nearest base station (m)');
% caxis([0 500])
% axis tight
% hold on
% 
% h2=imagesc(x,y,PR)
% set(h2, 'alphadata', ~isnan(PR))
% colorbar
% xlabel('Horizontal axis /m');
% ylabel('Vertical axis/m');
% title('Received power');
% caxis([-70 10])
% axis tight
% hold on
% 
% h3=imagesc(x,y,PI)
% set(h3, 'alphadata', ~isnan(PI))
% colorbar
% xlabel('Horizontal axis /m');
% ylabel('Vertical axis/m');
% title('Interference power');
% axis tight
% caxis([-80 -55])
% hold on

h4=imagesc(x,y,SIR)
set(h4, 'alphadata', ~isnan(SIR))
colorbar
xlabel('Horizontal axis /m');
ylabel('Vertical axis/m');
title('SIR');
caxis([-10 80])
axis tight
hold on
end

toc   

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).