Professional Documents
Culture Documents
Lab work
When we sample an analogue signal, we get discrete samples of analogue
signal. To represent the samples of the signal, we use difference
equation. Purpose of this lab is to show how to represent the difference
equation or samples of signals in MATLAB. We will also see different
interpretations of row vectors in MATLAB. In the end we will create a
moving averaging filter and see its effect on signal after filtering.
signal = x( n − 5) + 5 x( n − 4) −2 x( n −2) +8 x( n)
signal=[1 5 0 -2 0 1];
Samples = [0.3 1.7 3.3 5.4 2.6 ……] % this row vector represent the
difference equation
For MATLAB, a row vector is just a row vector; it cannot interpret what
each row vector is representing. It’s the programmer or user of MATLAB
who know what each row vector is representing. For example, when we
create a time vector given below
T=0:0.1:1;
Signal=cos(2*pi*3*t);
Digital Signal Processing
Lab tasks:
Step1:
• Create a signal represented by following difference equation
Signal= 2x[n-1]+4x[n-2]+6x[n-3]+8x[n-4]+10x[n-5]+8x[n-6]+
6x[n-7]+5x[n-8]+4x[n-9]+4x[n-10]+5x[n-11]+6x[n-12]+7x[n-13]+
5x[n-14]+3x[n-15]+3x[n-16]+7x[n-17]+7x[n-18]+3x[n-19]+3x[n-20]+
7x[n-21]+ 7x[n-22]+3x[n-23]+3x[n-24]+x[n-29]+2x[n-30]+3x[n-31]+
4x[n-32]+ 5x[n-33]+6x[n-34]+5x[n-35]+4x[n-36]+3x[n-37]+
2x[n-38]+1x[n-39];
• Plot it to see its graph
Step2:
• Create a moving averaging filter of length 2
1 1
Averaging_filter= x[n]+ x[n-1]
2 2
Step3:
• To apply filter to signal, we convolve them. Use conv command in
MATLAB to apply above filter to the signal. Plot the resultant
signal after applying filter to see the change.
TASK2
• Repeat the above steps using averaging filter of length 4.
• Repeat the above steps using averaging filter of length 8.