You are on page 1of 8

1

(P.T.O)
Digital Signal Processing Practical 2
1) Compute the linear convolution () () () of the following two sequences and
plot the result as a function of n:
() ( ) ( ) ( )
() ( ) () ( ) ( )

2) If the impulse response of a causal LSI system is () * +, what would be the
output y(n) of the system, if the discrete-time signal
()


Is applied at the input?

3) Cross correlation of two signals can be used to identify whether the signals are of the same
category or not. One such application of cross correlation is given below:
Let
() * +

be a prototype sequence, and let y(n) be its noise-corrupted and shifted version

() ( ) ()

where w(n) is Gaussian sequence with mean 0 and variance 1.
Compute the cross correlation between y (n) and x(n) and comment on the result.

4) Compute the auto correlation of x (n), defined in the above question (question 3), and
corrupted with a uniformly distributed random signal. Show that the result exhibits a peak at
zero lag.

5) Consider the following sequences:
() * +
() * +
() * +

Compute the autocorrelations of each of the above sequences.
What do you infer from the above computations?

6) Perform the cross correlation of the following:

()

()

() for the sequences in


question 5. Also, perform the cross correlation of the following:

()

()


What do you infer from the above operations?

7) A system is said to be Linear, if the following condition is satisfied:
,

()

()- ,

()- ,

()-
where T[.] is transformation of input at the output ( system operator).
Given below are three systems. Check analytically whether the systems are linear or not:
2

)

()

() )

() () )

() () ( ) ( )
x(n) is input and y(n) is the output.
Let x
1
(n) be a uniformly distributed random sequence between [0,1] over n = 0 to 100 and let
x
2
(n) be a Gaussian random sequence with mean 0 and variance 10 over n = 0 to 100. Using
these sequences, test the linearity of the above systems. You can use any value for a
1
and a
2
.
8) Three systems are given below:
)

,()- ()

,()- () ( ) )

()
Let x(n) be a Gaussian random sequence with mean 0 and variance 10 over n = 0 to 100.
Using these sequences, test whether the systems are shift invariant or not. You can use any
value for sample shift.
9) Consider the discrete-time system shown below:

() ()

( )

()

()

( )

() ()

() () ( ) ( ) ( )

Compute the impulse response of the equivalent system h
eq
(n) for the above system and
plot it as a function of n.
If ()

plot the output y(n) as a function of n.



Verify the answer by computing ()

()

()

()

() ()

()

() ()

()

()

()

()

()

()

() .

10) A relaxed LSI system is described by the difference equation
() ( ) ( ) () ( ) ( )
a) Determine the stability of the system
b) Determine and plot the impulse response of the system over Determine
the stability from this impulse response.
c) If the input to this system is () , () ()-() calculate
the response y(n) over
+
+
h
1
(n)
h
2
(n)
h
3
(n)
h
4
(n)
x(n)
w
2
(n)
w
3
(n)
w
1
(n)
w
4
(n)
y(n)
3

Random number generation to simulate noise
The built-in functions randn and rand can be used to generate random numbers which
can be added to a pure signal to simulate real signals. This type of real world signals
(signals with noise) can be used to verify the design of systems.
Commonly used functions to generate random numbers, with brief explanations, are
given below:

RANDN Normally distributed random numbers.
RANDN(N) is an N-by-N matrix with random entries, chosen from
a normal distribution with mean zero, variance one and standard
deviation one (square of standard deviation is variance).

RANDN(M,N) and RANDN([M,N]) are M-by-N matrices with random entries.
RANDN(M,N,P,...) or RANDN([M,N,P...]) generate random arrays.
RANDN with no arguments is a scalar whose value changes each time it
is referenced.

RANDN(SIZE(A)) is the same size as A.

>> n = 1:100;
>> randn(size(n));
>> gnoise = randn(size(n));
>> hist(gnoise)
>> title('Randn - Gaussian random sequence with mean zero and variance and standard
deviation 1');
>> mean(gnoise)

ans =

-0.0235

>> std(gnoise)

ans =

0.8723

The above calculations show that randn produces a normalized Gaussian random
sequence with standard deviation and variance close to one and mean value close to
zero. The histogram below shows that the random sequence generated are Gaussian
shaped (close to 68% data would be within 1 standard deviation from the mean).
4




>> stem(n,gnoise)
>> title('Randn - Gaussian random sequence with mean zero and variance and standard
deviation 1');
>> xlabel('n')
>> ylabel('Amplitude')


RAND Uniformly distributed random numbers.
RAND(N) is an N-by-N matrix with random entries, chosen from
a uniform distribution on the interval (0.0,1.0).

RAND(SIZE(A)) is the same size as A.

>> n = 1:100;
>> rnoise = rand(size(n));
>> hist(rnoise)
>> title('rand - unifromly distributed random numbers (0.0 to 1.0)')
>> mean(rnoise)
5


ans =

0.5286

>> std(rnoise)

ans =

0.2818



>> stem(n,rnoise)
>> title('rand - unifromly distributed random numbers (0.0 to 1.0)')
>> xlabel('n')
>> ylabel('Amplitude')


For example, let us generate a pure signal and add the noise to make the signal look
like real signal.
>> R = 50;
>> d = rand(R,1)-0.5;
>> m = 0:1:R-1;
>> s = 2*m.*(0.9.^m);
>> x = s + d';
>> subplot(2,1,1)
6

>> stem(m,s);
>> title('Signal uncorrupted by noise');
>> subplot(2,1,2)
>> stem(m,x);
>> title('Signal corrupted by noise');


The script files for computing the solutions for the questions in Digital signal Processing Practical
2 is given in the folder my_octave_programs\dsp_pract_2. You can either try these programs or
write your own script files (preferable). The names given to the files are q1.m for question 1,
q2.m for question 2 etc.

Note:
For questions 1 and 2 use the function conv_m.m
For questions 3 and 6 use the function xcroscorr.m
For questions 4 and 5 use the function xautocorr.m

Questions 7 and 8 are to be checked analytically. One can say whether a system is nonlinear or
shift variant by numerical methods. But, to prove that a system is linear or shift invariant by
numerical methods is bit risky. For example, refer the script file q8a1.m and q8a2.m given in the
folder my_octave_programs\dsp_pract_2. The first one produces a result which says the system
is shift invariant but q82.m says the system (same system) is shift variant. Therefore the system
is shift variant. This clearly says that one can prove a system as non linear or shift variant
numerically but one can not prove otherwise because for some conditions it may show non
linearity or shift variance.

For question 9, use conv_m.m

For question 10, use the built-in function filter to get the answers.

IIR and FIR systems
The system transfer function of an LSI system can be given as
()
()
()



7

()
()
()



()

()

()



()

()

()

()

()

()

()

()



The difference equation of the system is
()

( )

( )

( )

()

( )

( )

( )

The system is known as IIR (Infinite Impulse Response) system or ARMA (Autoregressive Moving
Average) system.

The roots of the denominator polynomial are called the poles of the system (H(z) goes to
infinity).

The roots of the numerator polynomial are called the zeroes of the system (H(z) goes to zero).

Special cases:

If all a
k
s, in the above generalized expression for IIR system, are zero, then the system is called
an FIR system or MA (moving average) system.
There are only zeros for this system. This is also known as feed forward system.
ie.,
()

()

()

()

()



()

()

( )

( )

The coefficients b
k
s are the impulse response of FIR system h
k
s

()

()

( )

( )

() *

+


If all b
k
s, except b
0
are zero, the system is called an AR (autoregressive) system. It is an all poles
system. This is also known as regressive / feed backward system.

()
()
()



8

()

()

()

()

()

()

()

()

()

( )

( )

( )

()

()

()

( )

( )

( )

In MATLAB, the IIR filters are described by the difference equation coefficients [b
k
] and [a
k
] and
are implemented by the built-in function filter(b, a, x), [b
k
] and [a
k
] are the coefficients
described above.

For question 10 a, use the built-in functon roots.m to get the poles of the system. If the poles
are less than 1, then the system is a stable causal system.
The difference equation of system in question 10 is
() ( ) ( ) () ( ) ( )
The coefficients of the systems are: a
0
= 1, a
1
= -0.5, a
2
= 0.25, b
0
= 1, b
1
= 2 and b
3
= 1.
One can get the pole(s) and check whether the system is stable or not by the executing the
following statements:
a = [1 -0.5 0.25];
b = [1 2 0 1];
% ----------------------------------------------------------
% Stability depends on the ROC which is determined by poles
% If the maximum (absolute) value of poles is < 1
% the system is stable causal system
% ----------------------------------------------------------
poles = roots(a);
if max(abs(poles)) < 1
disp('The system is a stable causal system')
else
disp('The system is unstable causal system')
end

The impulse response h(n) can be computed by using the built-in function filter(b,a,x) where b
and a are as defined above and x(n) = (n) (The output y(n) = h(n) if x(n) = (n)).

For question 10 c, the statement y = filter(b,a,x) ,where b and a are as defined above, and
() , () ()- over computes the output y(n).

You might also like