Sie sind auf Seite 1von 20

1, Path Loss Model

Path loss (or path attenuation) is the reduction in power density (attenuation) of
an electromagnetic wave as it propagates through space. Path loss is a major component in the
analysis and design of the link budget of a telecommunication system.
This term is commonly used in wireless communications and signal propagation. Path loss may be
due to many effects, such as free-space loss, refraction, diffraction, reflection, aperture-
medium coupling loss, and absorption. Path loss is also influenced by terrain contours, environment
(urban or rural, vegetation and foliage), propagation medium (dry or moist air), the distance between
the transmitter and the receiver, and the height and location of antennas.

Loss exponent
In the study of wireless communications, path loss can be represented by the path loss exponent,
whose value is normally in the range of 2 to 4 (where 2 is for propagation in free space, 4 is for
relatively lossy environments and for the case of full specular reflection from the earth surfacethe
so-called flat earth model). In some environments, such as buildings, stadiums and other indoor
environments, the path loss exponent can reach values in the range of 4 to 6. On the other hand, a
tunnel may act as a waveguide, resulting in a path loss exponent less than 2.
Path loss is usually expressed in dB. In its simplest form, the path loss can be calculated using the
formula

Prediction
Calculation of the path loss is usually called prediction. Exact prediction is possible only for simpler
cases, such as the above-mentioned free space propagation or the flat-earth model. For practical
cases the path loss is calculated using a variety of approximations.
Statistical methods (also called stochastic or empirical) are based on measured and averaged
losses along typical classes of radio links. Among the most commonly used such methods
are Okumura-Hata, the COST Hata model, W.C.Y.Lee, etc. These are also known as radio wave
propagation models and are typically used in the design of cellular networks and public land mobile
networks (PLMN). For wireless communications in the very high frequency (VHF) and ultra high
frequency (UHF) frequency band (the bands used by walkie-talkies, police, taxis and cellular
phones), one of the most commonly used methods is that of Okumura-Hata as refined by the COST
231 project. Other well-known models are those of Walfisch-Ikegami, W.C.Y. Lee, and Erceg. For FM
radio and TV broadcasting the path loss is most commonly predicted using the ITU model as
described in P.1546(successor to P.370) recommendation.
Deterministic methods based on the physical laws of wave propagation are also used; ray tracing is
one such method. These methods are expected to produce more accurate and reliable predictions of
the path loss than the empirical methods; however, they are significantly more expensive in
computational effort and depend on the detailed and accurate description of all objects in the
propagation space, such as buildings, roofs, windows, doors, and walls. For these reasons they are
used predominantly for short propagation paths. Among the most commonly used methods in the
design of radio equipment such as antennas and feeds is the finite-difference time-domain method.
The path loss in other frequency bands (medium wave (MW), shortwave (SW or
HF), microwave (SHF)) is predicted with similar methods, though the concrete algorithms and
formulas may be very different from those for VHF/UHF. Reliable prediction of the path loss in the
SW/HF band is particularly difficult, and its accuracy is comparable to weather predictions. [citation needed]
Easy approximations for calculating the path loss over distances significantly shorter than the
distance to the radio horizon:

In free space the path loss increases with 20 dB per decade (one decade is when the
distance between the transmitter and the receiver increases ten times) or 6 dB per octave(one
octave is when the distance between the transmitter and the receiver doubles). This can be used
as a very rough first-order approximation for (microwave) communication links;

For signals in the UHF/VHF band propagating over the surface of the Earth the path loss
increases with roughly 3540 dB per decade (1012 dB per octave). This can be used in cellular
networks as a first guess.

Examples
In cellular networks, such as UMTS and GSM, which operate in the UHF band, the value of the path
loss in built-up areas can reach 110140 dB for the first kilometer of the link between the base
transceiver station (BTS) and the mobile. The path loss for the first ten kilometers may be 150
190 dB (Note: These values are very approximate and are given here only as an illustration of the
range in which the numbers used to express the path loss values can eventually be, these are not
definitive or binding figuresthe path loss may be very different for the same distance along two
different paths and it can be different even along the same path if measured at different times.)
In the radio wave environment for mobile services the mobile antenna is close to the ground. Line-of-
sight propagation (LOS) models are highly modified. The signal path from the BTS antenna normally
elevated above the roof tops is refracted down into the local physical environment (hills, trees,
houses) and the LOS signal seldom reaches the antenna. The environment will produce several
deflections of the direct signal onto the antenna, where typically 2-5 deflected signal components will
be vectorially added.
These refraction and deflection processes cause loss of signal strength, which changes when the
mobile antenna moves (Raleigh fading), causing instantaneous variations of up to 20 dB. The
network is therefore designed to provide an excess of signal strength compared to LOS of 8-25 dB
depending on the nature of the physical environment, and another 10 dB to overcome the fading due
to movement.
Free space Path loss Model Math lab code

% Free Space Propagation Loss


clc;
close all;
clear all;

f = input('Enter carrrier frequency(MHz)');


c = 300;
d = 1:1:10000;
Lp =((4*pi*d*f)/c).^2;

subplot(2,1,1);
plot(d,Lp,'b');
xlabel('x--> D (distance in Km)');
ylabel('y--> Lp (path loss)');
title('Free space model');
grid on

subplot(2,1,2);
plot(d,10*log(Lp),'r');
xlabel('x--> D (distance in Meter)');
ylabel('y--> Lp (Path loss in dB)');
title('Free space model');
grid on;

3, shortest Path first Algorism

graphshortestpath
Solve shortest path problem in graph

Syntax
[dist, path, pred] = graphshortestpath(G, S)
[dist, path, pred] = graphshortestpath(G, S, T)
[...] = graphshortestpath(..., 'Directed', DirectedValue, ...)
[...] = graphshortestpath(..., 'Method', MethodValue, ...)
[...] = graphshortestpath(..., 'Weights', WeightsValue, ...)

Arguments
G N-by-N sparse matrix that represents a graph. Nonzero entries in matrix G represent the weights of the edges.

S Node in G.

T Node in G.

DirectedValu Property that indicates whether the graph is directed or undirected. Enter false for an undirected graph. This results in the u
e is true.
MethodValue Character vector that specifies the algorithm used to find the shortest path. Choices are:

'Bellman-Ford' Assumes weights of the edges to be nonzero entries in sparse matrix G. Time complexity is O
respectively.
'BFS' Breadth-first search. Assumes all weights to be equal, and nonzero entries in sparse matrix G to represent e
of nodes and edges respectively.
'Acyclic' Assumes G to be a directed acyclic graph and that weights of the edges are nonzero entries in sparse
number of nodes and edges respectively.
'Dijkstra' Default algorithm. Assumes weights of the edges to be positive values in sparse matrix G. Time co
nodes and edges respectively.

WeightsValue Column vector that specifies custom weights for the edges in matrix G. It must have one entry for every nonzero value (edge) i
match the order of the nonzero values in matrix G when it is traversed column-wise. This property lets you use zero-valued we
information from the nonzero entries in matrix G.

Description
[dist, path, pred] = graphshortestpath(G, S) determines the single-source shortest paths from
node S to all other nodes in the graph represented by matrix G. Input G is an N-by-N sparse matrix that
represents a graph. Nonzero entries in matrix G represent the weights of the edges. dist are
the N distances from the source to every node (using Infs for nonreachable nodes and 0 for the source
node). path contains the winning paths to every node. pred contains the predecessor nodes of the
winning paths.
[dist, path, pred] = graphshortestpath(G, S, T) determines the single source-single
destination shortest path from node S to node T.
[...] = graphshortestpath(...,
'PropertyName', PropertyValue, ...) calls graphshortestpath with optional properties that use
property name/property value pairs. You can specify one or more properties in any order.
Each PropertyName must be enclosed in single quotes and is case insensitive. These property
name/property value pairs are as follows:
[...] = graphshortestpath(..., 'Directed', DirectedValue, ...) indicates whether the graph
is directed or undirected. Set DirectedValue to false for an undirected graph. This results in the upper
triangle of the sparse matrix being ignored. Default is true.
[...] = graphshortestpath(..., 'Method', MethodValue, ...) lets you specify the algorithm
used to find the shortest path. Choices are:
'Bellman-Ford' Assumes weights of the edges to be nonzero entries in sparse matrix G.
Time complexity is O(N*E), where N and E are the number of nodes and edges respectively.
'BFS' Breadth-first search. Assumes all weights to be equal, and nonzero entries in sparse
matrix G to represent edges. Time complexity is O(N+E), where N and E are the number of nodes and
edges respectively.
'Acyclic' Assumes G to be a directed acyclic graph and that weights of the edges are
nonzero entries in sparse matrix G. Time complexity is O(N+E), where N and E are the number of nodes
and edges respectively.
'Dijkstra' Default algorithm. Assumes weights of the edges to be positive values in sparse
matrix G. Time complexity is O(log(N)*E), where N and E are the number of nodes and edges
respectively.
[...] = graphshortestpath(..., 'Weights', WeightsValue, ...) lets you specify custom
weights for the edges. WeightsValue is a column vector having one entry for every nonzero value (edge)
in matrix G. The order of the custom weights in the vector must match the order of the nonzero values in
matrix G when it is traversed column-wise. This property lets you use zero-valued weights. By
default, graphshortestpath gets weight information from the nonzero entries in matrix G.

Examples
Example 52. Finding the Shortest Path in a Directed Graph
1. Create and view a directed graph with 6 nodes and 11 edges.
W = [.41 .99 .51 .32 .15 .45 .38 .32 .36 .29 .21];
DG = sparse([6 1 2 2 3 4 4 5 5 6 1],[2 6 3 5 4 1 6 3 4 3 5],W)

DG =

(4,1) 0.4500
2. (6,2) 0.4100
3. (2,3) 0.5100
4. (5,3) 0.3200
5. (6,3) 0.2900
6. (3,4) 0.1500
7. (5,4) 0.3600
8. (1,5) 0.2100
9. (2,5) 0.3200
10. (1,6) 0.9900
11. (4,6) 0.3800
12.
13. h = view(biograph(DG,[],'ShowWeights','on'))
Biograph object with 6 nodes and 11 edges.
14. Find the shortest path in the graph from node 1 to node 6.
15. [dist,path,pred] = graphshortestpath(DG,1,6)
16.
17. dist =
18.
19. 0.9500
20.
21.
22. path =
23.
24. 1 5 4 6
25.
26.
27. pred =
28.
0 6 5 5 1 4
29. Mark the nodes and edges of the shortest path by coloring them red and increasing the line width.
30. set(h.Nodes(path),'Color',[1 0.4 0.4])
31. edges = getedgesbynodeid(h,get(h.Nodes(path),'ID'));
32. set(edges,'LineColor',[1 0 0])
set(edges,'LineWidth',1.5)

Example 53. Finding the Shortest Path in an Undirected Graph


1. Create and view an undirected graph with 6 nodes and 11 edges.
2. UG = tril(DG + DG')
3.
4. UG =
5.
6. (4,1) 0.4500
7. (5,1) 0.2100
8. (6,1) 0.9900
9. (3,2) 0.5100
10. (5,2) 0.3200
11. (6,2) 0.4100
12. (4,3) 0.1500
13. (5,3) 0.3200
14. (6,3) 0.2900
15. (5,4) 0.3600
16. (6,4) 0.3800
17.
18. h = view(biograph(UG,[],'ShowArrows','off','ShowWeights','on'))
Biograph object with 6 nodes and 11 edges.

19. Find the shortest path in the graph from node 1 to node 6.
20. [dist,path,pred] = graphshortestpath(UG,1,6,'directed',false)
21.
22. dist =
23.
24. 0.8200
25.
26.
27. path =
28.
29. 1 5 3 6
30.
31.
32. pred =
33.
0 5 5 1 1 3
34. Mark the nodes and edges of the shortest path by coloring them red and increasing the line width.
35. set(h.Nodes(path),'Color',[1 0.4 0.4])
36. fowEdges = getedgesbynodeid(h,get(h.Nodes(path),'ID'));
37. revEdges = getedgesbynodeid(h,get(h.Nodes(fliplr(path)),'ID'));
38. edges = [fowEdges;revEdges];
39. set(edges,'LineColor',[1 0 0])
set(edges,'LineWidth',1.5)

4 CDMA

For Transmitter
1. There are two different message signals of same length, each corresponding to an
individual user.
2. Now, converting each message signal into NRZ format.
Dept. of Electronics and Communication 19
3. Generation of PN sequences for both user, this PN sequence will act as a key for both
transmitting and receiving end.
4. Now, again converting PN sequences into NRZ format.
5. Spreading of message signal1 (user 1) by PN code1.
6. Spreading of user1 message signal is done by the Direct Sequence spreading.
7. Spreading of message signal2 (user 2) by PN code2.
8. Spreading of user2 message signal is done by the Direct Sequence spreading.
9. Addition of the both spread signal to form composite signal.
10. Now this composite signal is BPSK modulated.
11. Transmitting BPSK modulated signal using an AWGN channel at SNR=10.
4.2.2 For Receiver
1. At receiver side, Despreading of received signal for the user 1 by using PN code of
user 1.
2. This PN code works as key for the message signal of user 1.
3. BPSK Demodulation of despreaded signal of user1.
4. Synchronization of data of user1 i.e., Summation of each row of the BPSK
demodulated data of user 1.
5. Converting each analog data into digital data.
6. These converted data is similar to the original message signal of user1.
7. Despreading of received signal for the user 2 by using PN code of user 2.
8. This PN code works as key for the message signal of user 2.
9. BPSK Demodulation of despreaded signal of user2.
10. Synchronization of data of user2 i.e., Summation of each row of the BPSK
demodulated data of user 2.
11. Converting each analog data into digital data.
12. These converted data is similar to the original message signal of user2.
pnseqcdma.m
Function

clc;
clear all;
close all;
%%%%%%%%%%%%%%%%%USERS%%%%%%%%%%%%%%%%%%%%%%%
user1=randint(1,6)
user2=randint(1,6)

figure()
subplot(211);
stem(user1,'Color','b','LineWidth',2.5);
axis([0 7 -0.5 1.5]);
title('data for user1')
grid on;
subplot(212)
stem(user2,'Color','b','LineWidth',2.5);
axis([0 7 -0.5 1.5]);
title('data for user2')
grid on;

%%%%%%%%%%%%%%%%%TRANSMITTERS and MODULATERS%%%%%%%%%%%%%%%%%%%%%%%


% to convert the binary sequences to bipolar NRZ format

len_user1=length(user1);
len_user2=length(user2);
for i=1:len_user1
if user1(i)==0
user1(i)=-1;
end
end

for i=1:len_user2
if user2(i)==0
user2(i)=-1;
end
end

%plotting base band signal for user1


display_signal1=[];
for i=1:len_user1
for j=0.01:0.01:1 %0.01
if user1(i)==1
display_signal1=[display_signal1 1];
else
display_signal1=[display_signal1 -1];
end
end
end
len_disp=length(display_signal1);

% PN generator for user1

G=60;
sd=[0 0 0 0 0 1]; % defining polinomial=[1 0 0 0 0 1 1] for M Sequence

PN1=[];
for j=1:G
if sd(6)==sd(1)
temp1=0;
else temp1=1;
end
sd(1)=sd(2);
sd(2)=sd(3);
sd(3)=sd(4);
sd(4)=sd(5);
sd(5)=sd(6);
sd(6)=temp1;
PN1=[PN1 sd(6)];
end
figure(); % figure no.3
subplot(211)
stem(PN1,'Color','b','LineWidth',2.5);
axis([0 61 -0.5 1.5]);
grid on;
title('PN sequence for user1')
pnsample1=[];
len_PN1=length(PN1);
for i=1:len_PN1
for j=0.1:0.1:1
if PN1(i)==1
pnsample1=[pnsample1 1];
else
pnsample1=[pnsample1 -1];
end
end
end
len_pnsample1=length(pnsample1);
spdtx1=display_signal1.*pnsample1;
subplot(212)
stem(spdtx1,'Color','b','LineWidth',2.5);
axis([0 601 -1.5 1.5]);
grid on
title(' Spread Spectrum Signal Transmitted for user 1 is')

% plotting base band signal for user2


display_signal2=[];
for i=1:len_user2
for j=0.01:0.01:1
if user2(i)==1
display_signal2=[display_signal2 1];
else
display_signal2=[display_signal2 -1];
end
end
end

% PN generator for user2


G1=60;
sd1=[1 0 1 0 0 1]; % defining polinomial=[1 0 1 0 0 1] for M Sequence
PN2=[];
for j=1:G1
if sd1(6)==sd1(1)
temp3=0;
else temp3=1;
end
sd1(1)=sd1(2);
sd1(2)=sd1(3);
sd1(3)=sd1(4);
sd1(4)=sd1(5);
sd1(5)=sd1(6);
sd1(6)=temp3;
PN2=[PN2 sd1(6)];
end
figure(); % figure no.7
subplot(211)
stem(PN2,'Color','b','LineWidth',2.5);
axis([0 61 -0.5 1.5]);
grid on;
title('PN sequence user2')

pnsample2=[];
len_PN2=length(PN2);
for i=1:len_PN2
for j=0.1:0.1:1
if PN2(i)==1
pnsample2=[pnsample2 1];
else
pnsample2=[pnsample2 -1];
end
end
end
len_pnsample2=length(pnsample2);
spdtx2=display_signal2.*pnsample2;
subplot(212) % figure no.8
stem(spdtx2,'Color','b','LineWidth',2.5);
axis([0 606 -2.5 2.5]);
grid on;
title('spread spectrum signal transmitted for user 2 is')

spdtx=spdtx1+spdtx2;
subplot(212);
stem(spdtx2,'Color','b','LineWidth',2.5);
axis([0 601 -1.5 1.5]);
grid on
title(' Spread Spectrum Signal Transmitted for user 2 is')
lenspd=length(spdtx);

tb=1;
eb=1;
fc=180000;

% BPSK MODULATION FOR user


bpskmod=[];
for i=1:lenspd
for j=1:tb
bpskmod=[bpskmod sqrt(2*(eb/tb))*spdtx(i)*cos(2*pi*fc*j)];
end
end

% AWGN CHANNEL
composite_signal=awgn(bpskmod,10); % Syntax y = awgn(x,snr)
length(composite_signal);

%%%%%%%%%%%%%%%%% RECIEVER and DE-MODULATERS %%%%%%%%%%%%%%%%%%%%%%%


%DEMODULATION FOR user 1
rx1=composite_signal.*pnsample1;
figure(); % figure no.9
subplot(311)
plot(rx1,'Color','b','LineWidth',2.5);
axis([0 601 -5.0 5.0]);
title('rx1 SIGNAL');
grid on;
%BPSK DEMODULATION FOR user 1
demodcar1=[];
for i=1:lenspd
for j=1:tb
demodcar1=[demodcar1 sqrt(2*(eb/tb))*cos(2*pi*fc*j)];

end
end
bpskdemod1=rx1.*demodcar1;
% figure no.10
subplot(312)
plot(bpskdemod1,'Color','b','LineWidth',2.5);
axis([0 601 -6 6]);
title('o/p of bpsk demod for user 1 is ');
grid on;

len_dmod1=length(bpskdemod1);
sum=zeros(1,len_dmod1/100);
for i=1:len_dmod1/100
for j=(i-1)*100+1:i*100
sum(i)=sum(i)+bpskdemod1(j);
end
end
% sum
rxbits1=[];
for i=1:len_user1
if sum(i)>0
rxbits1=[rxbits1 1];
else
rxbits1=[rxbits1 0];
end
end

subplot(313)
stem(rxbits1,'Color','b','LineWidth',2.5);
axis([0 7 -0.5 1.5]);
title('rx 1 SIGNAL');
grid on;
disp('rxbits1=');
disp(rxbits1)

%DMODULATION FOR user 2


rx2=composite_signal.*pnsample2;
figure(); % figure no.11
subplot(311)
plot(rx2,'Color','b','LineWidth',2.5);
axis([0 601 -5 5]);
grid on;
title('rx2');

%%%% BPSK DEMODULATION FOR user 2


demodcar2=[];
for i=1:lenspd
for j=1:tb
demodcar2=[demodcar2 sqrt(2*(eb/tb))*cos(2*pi*fc*j)];
end

end
bpskdemod2=rx2.*demodcar2;
subplot(312) % figure no.12
plot(bpskdemod2,'Color','b','LineWidth',2.5);
axis([0 601 -6.0 6.0]);
grid on;
title('o/p of bpsk demod for user 2 is ');
len_dmod2=length(bpskdemod2);
sum=zeros(1,len_dmod1/100);
for i=1:len_dmod2/100
for j=(i-1)*100+1:i*100
sum(i)=sum(i)+bpskdemod2(j);
end
end
rxbits2=[];
for i=1:len_user2
if sum(i)>0
rxbits2=[rxbits2 1];
else
rxbits2=[rxbits2 0];
end
end

subplot(313)
stem(rxbits2,'Color','b','LineWidth',2.5);
axis([0 7 -0.5 1.5]);
title('rx 2 SIGNAL');
grid on;
disp('rxbits2=');
disp(rxbits2);

CDMA MATLAB Code


This section of MATLAB source code covers CDMA MATLAB code. CDMA
stands for Code Division Multiple Access.

As shown in the figure, CDMA uses codes to modulate the user data for
spreading in the transmitter. The same code is used at the receiver for
despreading. In actual CDMA system base station allocates different codes to
different users. Only the user having the correct code can only retrieve its
information back.

The block diagram covers CDMA transmitter and CDMA receiver. CDMA
transmitter consists of FEC encoder(convolution encoder), BPSK modulator and
spreading module. CDMA receiver consists of reverse modules of transmitter
part viz. despreading, BPSK demodulator and viterbi decoder.

Following is the CDMA matlab code and BER curve. BER curve is obtained after
passing the data through the AWGN.

CDMA MATLAB Code for 1 user


n1=1;
n2=14;
FFT_SIZE=256;
%CP=16;
conv_in=[];

%% Data Generator
Data_gen = randint(1,11,255)
Data_IN=dec2bin(Data_gen);
s=0;

%% BER PARAMETERS
EbNo=0:1:15;
BER = zeros(1,length(EbNo));
numPackets=15;
frmLen = 1000;
for idx = 1: length(EbNo)
for packetidx = 1 : numPackets

%% Convolution Encoder
conv_in=[];
for index =1:11
conv_in=[conv_in double(Data_IN(index,:))-48];
end
conv_in=[conv_in 0 0 0 0 0 0 0 0]; %%8 bits padding
DIN=conv_in;
trel = poly2trellis(7, [171 133]); % Define trellis.
code = convenc(conv_in,trel);
inter_out=code;

%% BPSK Data Mapping


mapper_out=mapping(inter_out',1,1);
clear inter_out;
D=mapper_out;
%% CDMA MATLAB TRANSMITTER
% encode bits and transmit
% CDMA specific parameters
C = [ -1 1 -1 1 ]; % code for the user which will be multiplied with
%data stream of the user#1 i.e.mapper_out
M = length(C); % length (number of bits) of code
Y = size(mapper_out);
N = Y(1); % number of unique senders / bit streams
I = Y(2); % number of bits per stream
T = []; % sum of all transmitted and encoded data on channel
RECON = []; % vector of reconstructed bits at receiver

G = zeros(I,M);
for n = 1:N
Z = zeros(I,M);
for i = 1:I
for m = 1:M
Z(i,m) = [D(n,i)*C(n,m)];
end
end
G = G + Z; %G is the data to be transmitted after IFFT
end
%% Adding AWGN
G = awgn(G./sqrt(16), EbNo(idx) , 'measured');
G = awgn(G./sqrt(16), EbNo(idx) , 'measured');
G = awgn(G./sqrt(16), EbNo(idx) , 'measured');
%% CDMA MATLAB RECEIVER
for n = 1:N
TOT = zeros(1,I);
R = zeros(I,M);
for i = 1:I
for m = 1:M
R(i,m) = G(i,m) * C (n,m);
TOT(i) = TOT(i) + R (i,m);
end
end
RECON = [RECON ; TOT / M];
end
RECON

rx_data1=RECON;
Demap_out=demapper(rx_data1,1,1);
%%viterbi decoder
vit_out=vitdec(Demap_out,trel,7,'trunc','hard');
DOUT=vit_out;
[number,ratio] = biterr(DIN,vit_out);
error(packetidx) = biterr(DIN,vit_out);

end % End of for loop for numPackets


BER21(idx) = sum(error)/(log2(4)*numPackets*frmLen);
end

h=gcf;clf(h); grid on; hold on;


set(gca,'yscale','log','xlim',[EbNo(1), EbNo(end)],'ylim',[0 1]);
xlabel('Eb/No (dB)'); ylabel('BER'); set(h,'NumberTitle','off');
set(h,'Name','BER Results');
set(h, 'renderer', 'zbuffer'); title('CDMA alone BER PLOTS');
semilogy(EbNo(1:end),BER21(1:end),'b-*');
BER Curve

6,Traffic Engineering Erlangb Function

%%Program to simulate blocking probability


%% Name: Fitsum lakew
%% Student no: PGComW/008/09
%% Hawassa University (2010)
%% ---------------------------Program----------------------------------
clc;
clear all;
close all;
C=[1 2 3 4 5 10 20 60]; % The number of Servers
rho=[0.1:0.1:100]; % Traffic intensity rho = lambda/mu
for i=1:length(C),
inc=0;
for q=0:C(i)
inc=inc+rho.^q/factorial(q);
end
pb(i,:)=rho.^C(i)./factorial(C(i))./inc;
end
figure(1)
loglog(rho,pb(1,:),'-b',rho,pb(2,:),'-b',rho,pb(3,:),'-b',...
rho,pb(4,:),'-b',rho,pb(5,:),'-b',rho,pb(6,:),'-b',rho,pb(7,:),'-b',...
rho,pb(8,:),'-b');
%% ----------------------------Plotting---------------------------------
xlabel('Traffic Intensity,A[Erlangs]');
ylabel('Probability of Blocking');
title('Probability of Blocking Vs Traffic Intensity');
axis([0.1 100 1e-4 1]);
text(2.e-1,0.15,'C=1');
text(3.2e-1,3e-2,'C=2');
text(4.8e-1,1e-2,'C=3');
text(7.2e-1,5e-3,'C=4');
text(1,3e-3,'C=5');
text(3.4,1.5e-3,'C=10');
text(9.8,1.6e-3,'C=20');
text(41,1.6e-3,'C=60');
grid on;
%% ------------------------------END------------------------------------

Das könnte Ihnen auch gefallen