Computation of the distance spectrum of convolutional codes and

advertisement
Computation of the distance
spectrum of convolutional
codes and the delay spectrum
of a network
(Semester Project)
Name: Guftaar Ahmad Sardar Sidhu
Majors: Communication Systems and Electronics
Supervisor: Prof. Dr. Werner Henkel
Tutor: Neele von Deetzen
Semester: Fall 2007
Institute: Jacobs University Bremen, Germany
1
Contents
1 Convolutional codes
1.1 Overview . . . . . . . . . . . . . . . . . . .
1.2 Representation of convolutional codes . . .
1.2.1 Generator polynomials . . . . . . .
1.2.2 Generator matrix . . . . . . . . . .
1.2.3 Tree diagram . . . . . . . . . . . .
1.2.4 State diagram . . . . . . . . . . . .
1.2.5 Trellis diagram . . . . . . . . . . .
1.2.6 Logic table . . . . . . . . . . . . .
1.3 Distance properties of convolutional codes
1.3.1 Free distance . . . . . . . . . . . .
1.3.2 Distance spectrum . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3
3
4
4
4
5
5
6
6
7
7
7
2 Computation of the distance spectrum and the free distance 9
2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2.1 Using Matlab’s symbolic math toolbox . . . . . . . . . 10
2.2.2 Without using Matlab’s symbolic math toolbox . . . . 11
3 A network application
3.1 Overview . . . . . . . . . . .
3.1.1 Network delay . . . .
3.1.2 Delay jitter . . . . .
3.2 Finding the delay spectrum
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
4 Codes
4.1 Finding distance spectrum by using symbolic math toolbox . .
4.2 Finding distance spectrum without using symbolic math toolbox
4.3 Finding Delay Spectrum(network delay and delay jitter) of a
Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
12
12
12
12
12
15
15
16
18
Chapter 1
Convolutional codes
1.1
Overview
A convolutional code is a type of error correcting code, first introduced by
Elias in 1955, in which each k-bit symbol is transformed into an n-bit symbol
where k/n is the code rate. Figure 1.1 shows a rate 1/2 convolutional encoder. The name convolutional codes is due to the fact that the input-output
Figure 1.1: Rate 1/2 convolutional encoder
relation is a convolution. The transfer function of a convolutional encoder
gives the relationship between the input sequence and the output sequence.
vij
=
∞
X
k=0
3
gkj ui−k .
where u is the input sequence, vj is output sequence at output j and gj
is an impulse response for output j. A binary convolutional code can be
represented by a three-tuple (n, k, m). The current n outputs are linear combinations of the present k input bits and the previous m · k input bits, where
m is the number of memory cells for each input sequence. The constraint
length L represents the maximum time interval out of the input sequence
that influences an output sample and hence L = m + 1. The constraint
length determines the power and complexity of a code. Convolutional codes
are used in applications such as cellular mobiles, satellite communication,
digital video and broadcasting etc.
1.2
Representation of convolutional codes
Following are the different ways of representing convolutional codes.
1.2.1
Generator polynomials
For the convolutional codes, we specify a set of n vectors, one for each of the
outputs. Each vector of the dimension m + 1 indicates the connection of the
shift register to that ouput, a ’1’ in the ith position of the vector indicates
that the corresponding shift register is connected to the modulo-2 adder and
a ’0’ indicates no connection. The generator polynomials for the rate 1/2
covolutional encoder shown in Fig.1.1 are
G0 (D) = 1 + D + D 2 and G1 (D) = 1 + D 2 .
and generally they are written as G0 =[1 1 1] and G1 =[1 0 1].
1.2.2
Generator matrix
A generator matrix of a convolutional code is a transfer function matrix of
the convolutional encoder. The generator matrix for a convolutional code can
define the code. The convolutional codes can be generated by a generator
matrix multiplied by the information sequence. If u and v are the polynimials
representing the information sequence and the output sequence respectively,
the relation between u and v can be characterized as v = u · G where G is the
generator matrix of the code. The generator matrix for the above encoder in
Fig.1.1 is
G(D) = (1 + D + D 2 1 + D 2 ) .
4
1.2.3
Tree diagram
The tree diagram shows the structure of the encoder in the form of a tree
with the branches representing the state transitions and nodes representing
the various states of the encoder. The tree diagram for our 1/2 encoder is
shown in Fig.1.2. An upward branch in Fig.1.2 corresponds to a ′ 0′ input
and downward direction corresponds to a ′ 1′ . The labels of the branches are
the corresponding code symbols and the nodes are labeled with the encoder
states.
Figure 1.2: Tree diagram
1.2.4
State diagram
Since the output of the encoder is determined by the input and the current
state of the encoder, a state diagram can be used to represent the encoding
process. The state diagram is simply a graph of the possible states of the
5
encoder and the possible transition from one state to the other. Figure 1.3
shows the state diagram of the 1/2-rate convolutional encoder of Fig.1.1.
Figure 1.3: State diagram
1.2.5
Trellis diagram
A tree structure repeats itself once the number of stages is greater than the
constraint length. It is observed that all branches emanating from two nodes
having the same state are identical in the sense that they generate identical
output sequence. So every two nodes having the same label can be merged.
By doing this throughout the tree diagram, we can obtain another diagram
called a trellis diagram which is a more compact representation. This is the
most common representation, especially, since it is the basis for the most
important Viterbi decoding algorithm. State diagram and trellis diagram
can be used to describe different properties of convolutional codes. Figure
1.4 shows the trellis diagram of the above encoder example.
1.2.6
Logic table
A logic table can also be built showing the outputs of the convolutional
encoder and the state of the encoder for all of the specific input sequence
present in the shift register.
6
Figure 1.4: Trellis diagram
1.3
Distance properties of convolutional codes
Following are different distance properties of convolutional codes.
1.3.1
Free distance
The free distance df ree of a convolutional code is the minimum Hamming
distance between different encoded sequences. In Fig.1.5 the path represented
by a bold line, is the path that is remerging to the all zero state with minimum
hamming weight. So in this case the free distance is df ree = 5.
Figure 1.5: Free distance
1.3.2
Distance spectrum
The distance spectrum of an (n, k) convolutional code is given by the function
T (W, D, L) =
∞ X
∞ X
∞
X
w=0 d=0 l=0
7
Tw,d,l · W w D d Ll ,
where W, D, and L are placeholders and w, d, and l represent the input
weight, the output weight, and the length of the sequence, respectively. n and
k are the number of output bits and the number of input bits of the encoder.
The coefficient Tw,d,l denotes the number of trellis paths with input weight
w, output weight d, and length l. For example, the expression 2W D 2L +
4W 2 D 3 L4 denotes T1,2,1 = 2 paths with input weight 1, output weight 2, and
length 1, as well as T2,3,4 = 4 paths with input weight 2, output weight 3,
and length 4.
8
Chapter 2
Computation of the distance
spectrum and the free distance
2.1
Overview
We know that the distance spectrum of a convolutional code is
T (W, D, L) =
∞
∞ X
∞ X
X
Tw,d,l · W w D d Ll .
w=0 d=0 l=0
The distance spectrum can easily be generated using the following formula.
T (W, D, L) =
∞
X
a · Si · b ,
i=0
where a, S, and b are vectors and matrices of dimensions [1 × 2M −1 ], [2M −1 ×
2M −1 ], and [2M −1 × 1]. The entries of a, S, and b are polynomial with the
placeholders W, D, and L, representing transitions in the trellis. In case of
no existing transition, the entry is 0. Otherwise, it is W w D d Ll . a defines
all transitions going from the all-zero state to other states, S describes the
transitions between all states except the all-zero state, and b represents the
transitions from all states except the all-zero state to the all-zero state.
2.2
Implementation
To find the distance spectrum by this matrix multiplication method a function in Matlab is implemented, which generates the distance spectrum of a
9
given convolutional code up to a certain length. Given is the length of the
longest paths to be considered as well as the trellis structure of the code.
Both are given as arguments to the function.
The trellis structure is handed over as a structure called trellis, containing
the fields ’next’ and ’out’. The fields ’next’ and ’out’ contain matrices of dimension [2M × 2k ] = [# trellis states × # possible input combinations]. The
entries of matrix trellis.nexti,j , where 0 ≤ i ≤ 2M − 1 and 0 ≤ j ≤ 2k − 1,
contain the following state of the current state i with input j, where i, j, and
the matrix entries themselves are the decimal representations of the binary
combinations with the least significant bit on the left. Consider an example
with 4 states, 2input bits,and 2 output bits: 

0 2 1 3
0 1 3 2
1 0 3 2
1 0 2 3



trellis.out
=
trellis.next = 
1 3 0 1
3 2 0 1
2 1 3 1
2 3 1 0
Here, in trellis.next the first row corresponds to transitions from state (0)10
to states (0)10 , (1)10 , (3)10 , (2)10 with inputs (0)10 , (2)10 , (1)10 , and (3)10 correspondingly, and e.g. the entry in the second row and third column represents the transition from state (1)10 = (10)2 to state (2)10 = (01)2 with input
(2)10 = (01)2 .
The same structural properties hold for the above trellis.out and its entries
denote the decimal representation of the binary encoder output. The first
row shows the decimal outputs with transition from state (0)10 = (00)2 to all
states with inputs (0)10 , (2)10 , (1)10 , and (3)10 . The function is implemented
by the following two approaches.
2.2.1
Using Matlab’s symbolic math toolbox
Here placeholders are defined as symbolic variables, i.e., W, D and L. All
computations are done with these variables. First of all a, S and b are computed and then the distance spectrum and the output spectrum are computed
on each path of trellis. For example for the above trellis structure a and b
are the vectors of dimensions [1 × 3] and S is a matrix of dimension [3 × 3].
The output of the Matlab function is the polynomial showing the weights of
different paths in the trellis with their corresponding lengths. The advantage
of this approach is its simple implementation, but on the other hand some
difficulties are also there e.g. there is no easy way to extract the powers (exponents) of variables which we need for most of the cases, and the symbolic
math toolbox is also not included in Matlab by default.
10
2.2.2
Without using Matlab’s symbolic math toolbox
This is a more complicated implementation. For each symbolic variable separate vectors are defined e.g. now instead of directly computing a, we have
aw, ad, and al containing input weights, output weights and length exponents respectively, and then a=[aw ad al]. Similarly Sw, Sd, Sl, bw, bd,
and bl are computed. Since now we are using powers of variables as entries of
vectors and a zero entry would not necessarily lead to a 0 in the polynomial,
so we would have to go for some other value to represent a 0 in the polynomial, just for this programming we are using −1 for the 0 in the polynomial.
Initially all vectors and matrices are initialized by −1. Since now vectors and
matrices contain binary numbers instead of variables, this is not the simple
matrix multiplication anymore, different sub functions are used to compute
the distance spectrum. This approach is more complicated to implement but
it solves the problems of the previous approach i.e., extracting the powers
of variables, since no symbolic variables are used at all, and also there is no
need of the symbolic math toolbox.
11
Chapter 3
A network application
3.1
Overview
The idea above is implemented on a small network which has some entities
(e.g., routers) and some costs (e.g., delay, delay jitter, capacity, packet loss
probability) belonging to transitions from one entity to another. Considering
the network like the state machine of a convolutional code, a trellis is built
from the network still with the costs on the paths. In the case of convolutional
codes, the costs (input/output weight, length) were all additive. The costs
of the network transitions may be multiplicative or even non-linear, but for
simplicity only additive costs (delay and delay jitter) are considered here.
We call the spectrum of these costs the delay spectrum.
3.1.1
Network delay
The network delay is the time for a packet to reach a network node from
another network node.
3.1.2
Delay jitter
The delay jitter is the difference between the transmission delays of two IP
packets.
3.2
Finding the delay spectrum
Here the task is to find the delay spectrum between two nodes of a network
(delay and delay jitter). A network matrix (delay matrix and delay jitter
12
matrix) with the source node n1 , which is the transmitter node, and the destination node n2 , which is the receiving node, are given. For example


0 5.3 4.5 8.7
5.2 0 9.5 4.2 

delay = 
4.4 9.9 0 5.1  .
8.6 17 6.1 0
The first row shows the delay between node n1 and all other nods, for example
delay1,2 = 5.3 means the delay from node n1 to node n2 is 5.3 milliseconds.
There are four rows which represent a total of four nodes in the network. The
corresponding state diagram is shown in Fig. 3.1. First of all the program
Figure 3.1: Network state diagram
computes the delay.out and jitter.out matrix of dimension [n − 1 × n − 1]
for two nodes, where n is the total number of nodes in the network. These
.out matrices are different from the .out matrix of convolutional codes because the source node n1 and the destination node n2 are on the same state
in trellis. Now we have a small number of states in the trellis. From .out,
matrices a, S, and b are computed and additionally the direct path delay Dp
is computed separately, where a shows all paths emerging from source node
n1 to all other nodes except the destination node n2 , S shows the transitions
between all nodes except the source node n1 and the destination node n2 ,
b shows all paths merging in the destination node n2 other than the direct
path. Dp shows the direct path delay (or jitter) between the source node
13
n1 and the destination node n2 , and the delay spectrum DS is given by the
formula
∞
X
DS = Dp +
a · Si · b .
i=0
i
where (a · S · b) gives the delays of paths with (i + 1) intermediate nodes
in between where intermediate nodes are all nodes except source and destination node. If we want to send data from node 1 to node 4, for the delay
matrix first of all delay.out is computed to find the delay between these two
nodes


5.3 4.5 8.7
delay.out = 0 9.5 4.2 .
9.9 0 5.1
The column entries of first row of this matrix represent the dealys between
the first node 1 and the nodes 2, 3, and 4, similarly second row represent
dealys between the node 2 and the nodes 2, 3, and 4 repectively. From
delay.out the following variables are computed.
4.2 5.3
D
0 D 9.5
4.5
8.7
D
,
b= 5.1 .
Dp = D ,
a= D
,
S= 9.9
D
D
0
and finally the delay spectrum is DS = D 8.7 + D 9.5 + D 9.6 + D 18.6 + D 19.9 ,
which shows there are four paths going from node 1 to node 4 with delays
8.7ms, 9.5ms, 18.6ms, and 19.9ms.
14
Chapter 4
Codes
4.1
Finding distance spectrum by using symbolic math toolbox
function [a,s,b,T,Td,fd]=dist spect(trellis,LL)
trellis next=trellis.next;
trellis out=trellis.out;
syms W D L s a b T a2 b2 s2 Td fd;
% W=Input weight, % D=Output weight, % L=path
% a2,s2 and b2 introduced to calculate output spectrum, theses are same as ’a’,’s’
and ’b’ but these only have D
T=0; % ditance spectrum
Td=0;%output spectrum
fd=0;%free distance
lef t[m,nright]=size(trellis next); % to define the size of a,s and b
%Initialization of a
for jj=1:m-1, a(1,jj)=0; a2(1,jj)=0; end
% Initialization of ’S’
for ii=1:m-1, for jj=1:m-1, s(ii,jj)=0; s2(ii,jj)=0; end, end
% Initialization of ’b’
for ii=1:m-1, b(ii,1)=0; b2(ii,1)=0; end
% Computation of ’a’
i=1; for j=1:n, temp=trellis next(i,j);
if temp>0, % not going to zero state
tempbin1=de2bi(j-1);% Calculation of input weight(no of 1’s)
w=sum(tempbin1); tempbin2=de2bi(trellis out(i,j)); % Calculation of output weight(no
of 1’s)
d=sum(tempbin2); a(i,temp)=W w * D d * L; a2(i,temp)=D d̂; end, end
% Computation of ’S’
for i=2:m; for j=1:n, temp1=trellis next(i,j);
15
if temp1>0,
tempbin3=de2bi(j-1);% Calculation of input weight(no of 1’s)
, w=sum(tempbin3);
tempbin4=de2bi(trellis out(i,j)); % Calculation of output weight(no of 1’s)
d=sum(tempbin4); s(i-1,temp1)=Wŵ Dd̂ L; s2(i-1,temp1)=Dd̂; end, end, end
% Coputation of ’b’
for i=2:m, for j=1:n, temp2=trellis next(i,j);
if temp2==0 % transition to zero state
tempbin5=de2bi(j-1);% Calculation of input weight(no of 1’s)
w=sum(tempbin5);ctr5=0;
tempbin6=de2bi(trellis out(i,j));% Calculation of output weight(no of 1’s)
d=sum(tempbin6); b(i-1,1)=Wŵ Dd̂ L; b2(i-1,1)=Dd̂; end, end, end
% Distance spectrum and output spectrum for i=2:LL, T=T+a sˆ(i-2)* b; Td=simplify(Td+
a2 s2ˆ(i-2)* b2); end
fd=a2 s2 b2; % free distance
4.2
Finding distance spectrum without using
symbolic math toolbox
function [a,s,b,T,Td,fd]=dist spect2(trellis,len)
trellis next=trellis.next;
trellis out=trellis.out;
T=0;%ditance spectrum
Td=0;%output spectrum
fd=0;%free distance
lef t[m,nright]= size(trellis next);% to define the size of a,s and b
%Initialization of a
aw=-ones(1,m-1);% aw contains input weights going from ’zero’ state state to all
other states
ad=-ones(1,m-1);% ad contains output weights going from ’zero’ state state to all
other states
al=-ones(1,m-1);% al contains output weights going from ’zero’ state state to all
other states
%Initialization of S
sw=-ones(m-1,m-1);% sw contains input weights going from all non zero states to
all non zero states
sd=-ones(m-1,m-1); sl=-ones(m-1,m-1); %Initialization of b
bw=-ones(m-1,1);% bw contains input weights going from all non zero states to
zero state
bd=-ones(m-1,1); bl=-ones(m-1,1); %Computation of a,
i=1;for j=1:n, temp=trellis next(i,j);
16
if temp>0% not going to zero state
tempbin1=de2bi(j-1);% Calculation of input weight(no of 1’s)
w=sum(tempbin1); aw(i,temp)=w; tempbin2=de2bi(trellis out(i,j));% Calculation of output weight(no of 1’s)
d=sum(tempbin2); ad(i,temp)=d;
if w>=0,
al(i,temp)=1; end,
if d>=0, al(i,temp)=1; end, end, end
a=[aw,ad,al];
%Computation of S
for i=2:m, for j=1:n, temp1=trellis next(i,j);
if temp1>0,
tempbin3=de2bi(j-1);%Calculation of input weight(no of 1’s)
w=sum(tempbin3); sw(i-1,temp1)=w, tempbin4=de2bi(trellis out(i,j));%Calculation
of output weight(no of 1’s)
d=sum(tempbin4); sd(i-1,temp1)=d;
if w>=0,
sl(i-1,temp1)=1; end,
if d>=0,
sl(i-1,temp1)=1; end, end, end, end
s=[sw,sd,sl];
%Coputation of b
for i=2:m, for j=1:n, temp2=trellis next(i,j);
if temp2==0 %transition to zero state
tempbin5=de2bi(j-1); w=sum(tempbin5); bw(i-1,1)=w; tempbin6=de2bi(trellis
out(i,j)); d=sum(tempbin6); bd(i-1,1)=d;
if w>=0, bl(i-1,1)=1; end,
if d>=0, bl(i-1,1)=1; end, end, end, end
b=[bw,bd,bl];
%Distance spectrum and output spectrum
for ii=1:len-2, [aw]=my mult1(aw,sw); % Multiplying a*s,(a*s, a*s*s, a*s*s*s etc
depending on length)
lef t[ ad right]=my mult1(ad,sd); lef t[alright]=my mult1(al,sl);lef t[asbwright]]=my
mult2(aw,bw); % Multiply ’a s,a s2̂,... with ’b’
lef t[asbdright]=my mult2(ad,bd); [asbl]=my mult2(al,bl);
if ii==1 % combining a s b, a s2̂ b,....
Tw=asbw; Td=asbd; Tl=asbl;
else, Tw=[Tw asbw]; Td=[Td asbd]; Tl=[Tl asbl]; end, end
T=[Tw;Td;Tl];
Td=T(2,:);% D’s are in second row of T
fd=min(Td);
end% end of function
17
subfunction my mult1
function [T1]=my mult1(a,s) lef t[sm,snright]=size(s); [am,an]=size(a); temp=an/sm;%
crireria to decide how many elements (columns) of ’a’ multiply with one element
of ’s’
p=1; T1=-ones(1,an*sm); for k=1:sm, for j=1:sn, for i=(j-1)*(temp)+1:j*temp
if a(1,i)>=0& & s(j,k)>=0, T1(1,p)=a(1,i)+s(j,k); end, p=p+1, end, end, end,
end
subfunction my mult2
function [T]=my mult2(as,b) lef t[bm,bnright]=size(b);
lef t[am,anright]=size(as); temp=an/bm;% crireria to decide how many elements(columns)
of ’as’ multiply with one element of b
p=1; T1=-ones(1,an); for j=1:bn, for i=(j-1)*(temp)+1:j*temp,
if as(1,i)>=0& & b(j,1)>=0, T1(1,p)=as(1,i)+b(j,1); end, p=p+1, end, end
% finally remove all ”-1’s” and get the values in new matrix
q=1; for ii=1:an,
if T1(1,ii)>0,
T(1,q)=T1(1,ii); q=q+1; end, end
4.3
Finding Delay Spectrum(network delay
and delay jitter) of a Network
function [a,s,b,DS]=network(network,n1,n2,len)
ND=network.delay; NJ=network.jitter; syms J D L s a b DS;
lef t[m,nright]=size(ND);
% generation of my delay.out and delay jitter.out matrices from network matrix
t1=1; t2=1;
for i=1:m,
if (i=n2),
˜
for j=1:n,
if(j =n1), d out(t1,t2)=ND(i,j); j out(t1,t2)=NJ(i,j); t2=t2+1; end, end, t1=t1+1;
t2=1; end, end
lef t[om,onright]=size(d out); lef t[jm,jnright]-=size(j out);
% computation of direct path delay ’Dp’ and direct path delay jitter ’Dpj’ and ’a’
which is all path emerging from source node execpt direc path
if (n1<n2)% if the source node is above the destination node in matrix (Row
N0.(source)<Row No.(dest))
Dp(1,1)=d out(n1,n2-1);% Direct path delay from source to destination
Dpj(1,1)=j out(n1,n2-1);
if n2==n% if the dest node is the last node
temp a=d out(n1,1:on-1); temp aj=j out(n1,1:jn-1);
18
else, temp a1=d out(n1,1:n2-2); temp a2=d out(n1,n2:on); temp a=[temp
a1 temp a2]; temp aj1=j out(n1,1:n2-2); temp aj2=j out(n1,n2:jn); temp
aj=[temp aj1 temp aj2]; end,
else% if the source node is below the destination node in matrix(Row No.(src)¿Row
No.(dest))
Dp=d out(n1-1,n2); Dpj=j out(n1-1,n2);
if n2==1,
temp a=d out(n1-1,2:on); temp aj=j out(n1-1,2:jn);
else, temp a1=d out(n1-1,1:n2-1); temp a2=d out(n1-1,n2+1:on); temp a=[temp
a1 temp a2];
temp aj1=j out(n1-1,1:n2-1); temp aj2=j out(n1-1,n2+1:jn); temp aj=[temp
aj1 temp aj2]; end, end
lef t[am,anright]=size(temp a);
for i=1:am, for j=1:an, d=temp a(i,j); dj=temp aj(i,j); a(i,j)=Dd̂ Jd̂j L;% ’a’
containing delay and delay jitter from source node to all other nodes except destination
end, end
D p=DD̂p JD̂pj L;
temp a
% Computation of b i.e all path merging in destination node except direct path
if(n1<n2),
if n1==1
temp b=d out(2:om,n2-1); temp bj=j out(2:jm,n2-1);
else, temp b1=d out(1:n1-1,n2-1); temp b2=d out(n1+1:om,n2-1);
temp b=[temp b1;temp b2]; temp bj1=j out(1:n1-1,n2-1);
temp bj2=j out(n1+1:jm,n2-1); temp bj=[temp bj1;temp bj2]; end
else,
if n1==n, temp b=d out(1:n1-2,n2); temp bj=j out(1:n1-2,n2);
else, temp b1=d out(1:n1-2,n2); temp b2=d out(n1:om,n2); temp b=[temp
b1;temp b2]; temp bj1=j out(1:n1-2,n2);
temp bj2=j out(n1:jm,n2); temp bj=[temp bj1;temp bj2]; end, end
lef t[bm,bnright]=size(temp b); for i=1:bm, for j=1:bn, d=temp b(i,j); dj=temp
bj(i,j); b(i,j)=Dd̂ Jd̂j L; end, end
% Computation of ’S’
if n1<n2
temp1=d out(1:n1-1,1:on); temp2=d out(n1+1:om,1:on); tempr=[temp1;temp2];
lef t[tmtnright]=size(tempr); temp3=tempr(1:tm,1:n2-2); temp4=tempr(1:tm,n2:tn);
temp s=[temp3 temp4]; temp1j=j out(1:n1-1,1:jn); temp2j=j out(n1+1:jm,1:jn);
temprj=[temp1j;temp2j]; lef t[tjm,tjnright]=size(temprj); temp3j=temprj(1:tjm,1:n22); temp4j=temprj(1:tjm,n2:tjn); temp sj=[temp3j temp4j];
else
temp1=d out(1:n1-2,1:on); temp2=d out(n1:om,1:on); tempr=[temp1;temp2];
[tm,tn]=size(tempr); temp3=tempr(1:tm,1:n2-1);
19
temp4=tempr(1:tm,n2+1:tn); temp s=[temp3 temp4]; temp1j=j out(1:n1-1,1:jn);
temp2j=j out(n1+1:jm,1:jn);
temprj=[temp1j;temp2j]; [tjm,tjn]=size(temprj); temp3j=tempr(1:tjm,1:n2-2); temp4j=temprj(1:tjm,n2:
temp sj=[temp3j temp4j]; end
lef t[sm,snright]=size(temp s);
for i=1:sm, for j=1:sn
d=temp s(i,j); dj=temp sj(i,j);
if(d==0 && dj==0), s(i,j)=0;
else, s(i,j)=Dd̂ Jd̂j L; end, end, end
% computation of delay spectrum
DS=0;
for i=2:len
DS=DS+D p+a s ˆ(i-2)* b+a * b;
end
20
Download