MATLAB Signal Processing Guide
MATLAB Signal Processing Guide
8.
9.
10.
1
EXPERIMENT NO: 1
AIM:
Introduction to MATLAB.
APPARATUS REQUIRED:
INTRODUCTION TO MATLAB:
2
PROCEDURE:
3
EXPERIMENT NO: 2
AIM:
Write a program for the generation of basic signals such as unit impulse, unit step, ramp,
exponential, sinusoidal and cosine.
APPARATUS REQUIRED:
4
y=square(t);
subplot(3,3,3);
plot(t,y,'m');
xlabel('Time');
ylabel('Amplitude');
title('Square wave');
% (triangular)
subplot(3,3,5);
plot(t,y, 'r');
ylabel ('Amplitude');
xlabel ('Time Index');
title('Triangular waveform');
5
RESULT:
Amplitude
Amplitude
0 0 0
-1 -1 -1
0 5 10 0 5 10 0 5 10
Time Time Time
Sawtooth wave Triangular waveform Sinc Pulse
1 2 1
0.5 1
Amplitude
Amplitude
Amplitude
0.5
0 0
0
-0.5 -1
-1 -2 -0.5
0 5 10 -10 0 10 -10 0 10
Time Time Index Time Index
6
Exponential
x 10 growing Signal Exponential decaying Signal
10 1
Amplitude
Amplitude
5 0.5
0 0
0 5 10 0 5 10
Time Index Time Index
Thus the MATLAB program triangular, Square, Saw tooth and sinc plotted. Time
Signals) programs for functional sequence of a signal (Sine, Cosine) using MATLAB
function written and the results were plotted.
6
EXPERIMENT NO: 3
AIM:
To write MATLAB programs to find out the linear convolution of two sequences.
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: MATLAB 7.8
PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.
PROGRAM: (Linear Convolution)
INPUT:
>> LIN_CONVOLUTION
Enter x: [1 2 3 4 5]
x =
1 2 3 4 5
Enter h: [1 2 3 1]
7
h =
1 2 3 1
Y =
1 4 10 17 24 25 19 5
RESULT:
Thus the MATLAB program written and the results were plotted.
8
EXPERIMENT NO: 4
AIM:
To write MATLAB programs to find out the Circular convolution of two sequences.
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: MATLAB 7.8
PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.
9
end
end
disp('The output sequence is y(n)= ');
disp(y);
stem(y);
title('Circular Convolution');
xlabel('n');
ylabel('y(n)');
INPUT:(Circular Convolution)
enter the sequence x(n) = [1 2 3 4]
enter the sequence h(n) = [1 2 1 1]
The output sequence is y(n)=
14 11 12 13
RESULT:
Thus the MATLAB program written and the results were plotted.
10
EXPERIMENT NO: 5
AIM:
Implement IIR Butterworth analog low pass filter for a 4 KHz cut off frequency in
MATLAB using IIM.
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: MATLAB 7.8
PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.
PROGRAM:
11
ENTER THE FILTER ORDER N = 3
ENTER THE SAMPLING FREQUENCY fs = 1500
ENTER THE CUT-OFF FREQUENCY fc = 4
RESULT:
AMPLITUDE RESPONSSE
0
-50
Magnitude---->
-100
-150
-200
0 100 200 300 400 500 600 700 800
Frequency---->
POLE-ZERO PLOT
1
Imaginary part---->
0.5
-0.5
-1
-3 -2 -1 0 1 2 3
Real part---->
12
EXPERIMENT NO: 6
AIM:
Write a MATLAB program to design the IIR Butterworth Using Bilinear Transformation
method.
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: MATLAB 7.8
PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.
PROGRAM:
13
p=roots(d);
xlabel('RREAL PART---->');
ylabel('IMAGINARY PART');
title('POLE-ZERO PLOT');
RESULT:
14
EXPERIMENT NO: 7
AIM:
To verify FFT in MATLAB.
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: MATLAB 7.8
PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.
PROGRAM:
%%%%%%%%%%%%%PROGRAM %%%%%%%%%%%%%
N=input('type length of DFT= ');
T=input('type sampling period= ');
freq=input('type the sinusoidal freq= ');
k=0:N-1;
f=sin(2*pi*freq*1/T*k);
F=fft(f);
stem(k,abs(F));
grid on;
xlabel('k');
ylabel('X(k)');
INPUT:
type length of DFT= 32
type sampling period= 64
type the sinusoidal freq= 11
>>
OUTPUT:
15
16
EXPERIMENT NO: 8
AIM:
To write a program for calculation of DFT using MATLAB.
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: MATLAB R 7.8
PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.
PROGRAM:
subplot (2,1,1);
stem(k,mgXk);
title ('DFT sequence: ');
xlabel('Frequency');
ylabel('Magnitude');
subplot(2,1,2);
stem(k,phaseXk);
title('Phase of the DFT sequence');
xlabel('Frequency');
ylabel('Phase');
INPUT:
Input sequence: [1 4 5 7 6 7 4 13 12]
Enter the number of points: 9
L =
9
RESULT:
DFT X(k):
59.0000
-1.3336 +10.7647i
-8.6775 +12.5699i
-11.5000 + 0.8660i
-3.4889 - 5.9890i
-3.4889 + 5.9890i
-11.5000 - 0.8660i
-8.6775 -12.5699i
-1.3336 -10.7647i
DFT sequence:
60
Magnitude
40
20
0
0 1 2 3 4 5 6 7 8
Frequency
Phase of the DFT sequence
4
2
Phase
-2
-4
0 1 2 3 4 5 6 7 8
Frequency
EXPERIMENT NO: 8
AIM:
To write a program for calculation of IDFT using MATLAB.
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: MATLAB R 7.8
PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.
PROGRAM:
INPUT:
Input sequence X(k): [1 4 5 -6 -8 9]
RESULT:
xn =
0.8333
2.5000 + 1.1547i
-1.6667 - 2.5981i
-1.5000 + 0.0000i
-1.6667 + 2.5981i
2.5000 - 1.1547i
xn
0.8333
2.5000 + 1.1547i
-1.6667 - 2.5981i
-1.5000 + 0.0000i
-1.6667 + 2.5981i
2.5000 - 1.1547i
IDFT
3
2.5
1.5
1
Amplitude
0.5
-0.5
-1
-1.5
-2
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
time
EXPERIMENT NO: 10
AIM:
To write a program to design the FIR low pass and High pass filters using Blackman
window using MATLAB.
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: MATLAB R 7.8
PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.
PROGRAM:
50
0
Gain (dB)
-50
-100
-150
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Frequency
50
0
Gain (dB)
-50
-100
-150
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Frequency
Thus the program to design FIR low pass and high pass Filters using Blackman Window
is written and response of the filter using MATLAB are executed.
EXPERIMENT NO: 11
AIM:
To write a program to design the FIR low pass and High pass filters using Hamming
window using MATLAB.
APPARATUS REQUIRED:
HARDWARE: Personal Computer
SOFTWARE: MATLAB 7.8
PROCEDURE:
1. Start the MATLAB program.
2. Open new M-file
3. Type the program
4. Save in current directory
5. Compile and Run the program
6. If any error occurs in the program correct the error and run it again
7. For the output see command window\ Figure window
8. Stop the program.
Input Parameters
Enter Pass band Ripple: 0.02
Enter Stop band Ripple: 0.01
Enter Pass band Frequency: 1200
Enter Stop band Frequency: 1700
Enter Sampling Frequency: 9000
>>
50
0
Gain (dB)
-50
-100
-150
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Frequency
50
0
Gain (dB)
-50
-100
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Frequency
RESULT:
Thus the program to design FIR low pass and high pass Filters using HAMMING
Window is written and response of the filter using MATLAB are executed.