Академический Документы
Профессиональный Документы
Культура Документы
Coimbatore
DEPARTMENT OF ECE
CERTIFICATE OF COMPLETION
It is certified that this is the bonafide record of work done by
Name:..
Register Number:.Year of Batch:.................
Year:..Semester:.
STAFF INCHARGE
HOD
CERTIFICATE OF COMPLETION
We here by certify that the above record work was submitted for University
Practical Examination held on ..
INTERNAL EXAMINER
EXTERNAL EXAMINER
INDEX
SL. NO.
DATE
EXPERIMENT NAME
PAGE
MARK
NO.
(15)
SIGN
CYCLE-I(USING MATLAB)
1.
2.
3.
4.
5.
6.
7.
Generation of signals
9.
Linear convolution
10.
11.
12.
Calculation of FFT.
TOTAL
AVERAGE
EX. NO:
DATE:
AIM:
To write a MATLAB program to generate a following standard input signals (i)Unit step, (ii)
Unit impulse ,(iii) Unit ramp, (iv) Sinusoidal signal, (v)Saw tooth wave, (vi) Square wave, (vii)
Exponential signal and plot their response in Discrete and continuous time domain.
APPARATUS REQUIRED:
HARDWARE: IBM PC (OR) Compatible PC
SOFTWARE: MATLAB 6.5 (OR) High version
A.UNIT STEP SEQUENCE:
MATHEMATICAL EQUATION:
u(n) = 1 for n >= 0
= 0 for n < 0
THEORY:
The unit step sequence is a signal that is zero everywhere expect at n >= 0 where its
value is unity. In otherwise integral of the impulse function is also a singularity function and called
the unit step function.
ALGORITHM:
Step 1: Start the program
Step 2: Get the dimension of n
Step 3: Discrete output is obtained for n>= 0 and zeros for all other values.
Step 4: Output is generated in stem format
Step 5: Terminate the process
B.UNIT IMPLULSE SEQUENCE:
MATHEMATICAL EQUATION:
(n) = 1
=0
for n = 0
for n 0
THEORY:
The unit impulse (sample) sequence is a signal that is zero everywhere except at n=0 where
it is unity. This signal sometime referred to as unit impulse.
ALGORITHM:
Step 1: Start the program
Step 2: Get the dimension of n
Step 3: Discrete output is obtained for n = 0 and zeros for all other values.
Step 4: Output is generated in stem format
Step 5: Terminate the process
for n >= 0
for n< 0
THEORY:
This unit ramp sequence is signal that grows linearly when n>=0, otherwise it is zero.
ALGORITHM:
Step 1: Start the program
Step 2: Get the dimension of n
Step 3: Discrete output is obtained for n>=0 and zeros for all other values
Step 4: Output is generated in stem format
Step 5: Terminate the process
D.SINUSOIDAL SEQUENCE:
MATHEMATICAL EQUATION:
X(n) = A sin (o n + )
Where o frequency in radians/sec, and is the phase angle in radians.
ALGORITHM:
Step 1: Start the program
Step 2: Get the dimension of n
Step 3: For each value of n find the sine format
Step 4: Output is generated in stem(plot) format
Step 5: Terminate the process
E.SAWTOOTH WAVE:
ALGORITHM:
Step 1: Start the program
Step 2: Get the dimension of n
Step 3: For each value of n find the sawtooth format
Step 4: Output is generated in stem(plot) format
Step 5: Terminate the process
F. SQUARE WAVE:
ALGORITHM:
Step 1: Start the program
Step 2: Get the dimension of n
Step 3: For each value of n find the square format
Step 4: Output is generated in stem(plot) format
Step 5: Terminate the process
G.EXPONENTIAL SEQUENCE:
MATHEMATICAL EQUATION:
X (n) = an for all n
THEORY:
When the values of a>1, the sequence grows exponentially and when the value is 0<a<1, the
sequence decay exponentially.
ALGORITHM:
Step 1: Start the program
Step 2: Get the dimension of n
Step 3: discrete output is obtained for n>= 0 and zeros for all other values
Step 4: Output is generated in stem(plot) format
Step 5: Terminate the process
E.SAWTOOTH WAVE:
PROGRAM:
% sawtooth sequence
t = 0:0.1:5;
y = sawtooth (2*pi*t);
stem (t,y);
title ('sawtooth sequence');
xlabel ('time');
ylabel ('amplitude');
F. SQUARE WAVE:
PROGRAM:
%square sequence
clf;
t=0:0.1:5;
y=square(2*pi*t);
figure(1);
stem(t,y);
title('square sequence in continuous domain');
xlabel('time');
ylabel('amplitude');
%axis([0 20 -2 2]);
G.EXPONENTIAL SEQUENCE:
PROGRAM:
%program to generate exponential sequence
clf;
t=0:10;
y=exp(0.3*t);
figure(1);
stem(t,y);
grid;
title('Exponential sequence');
xlabel('time');
ylabel('amplitude');
n = -10:10
OUTPUT:
n = -20:20
D.SINUSOIDAL SEQUENCE:
INPUT:n = 0: 0.1:pi
OUTPUT:
e.SAWTOOTH WAVE:
INPUT: n = 0 : 0.1: 5
OUTPUT:
F. SQUARE WAVE:
INPUT: n =0:0.1:5
OUTPUT
G.EXPONENTIAL SEQUENCE:
INPUT:n = 0:10
OUTPUT:
RESULT:
Thus the MATLAB programs for unit step, unit impulse, unit ramp, sinusoidal signal saw
tooth, square wave, exponential signals were generated and their responses were plotted in discrete
and continuous time domain successfully.
EX.NO:
DATE
DATE :
= WkN
The FFT is a method for computing the DFT with reduced number of calculations. The
computational efficiency is achieved if we adopt a divide and conquer approach. This approach is
based on the decomposition of an N- point DFT into smaller DFTs.
In an N-point sequence, if N can be expressed as N= rm , then the sequence can be decimated
into r- point sequences. For each r- point sequence, r- point DFT can be computed. From the results
of r-point DFT, r2-point DFTs are computed. From the results of r2-point DFTs, the r3-point DFTs
are computed and so on, until we get rm-point DFT.In computing N-point DFT by this method a
number of stages of computation will be m times. The number r is called Radix of the FFT
algorithm.
ALGORITHM:
Step 1: Start the program.
Step 2: Get the finite duration sequence x(n).
Step 3: Calculate the value of N.
Step 4: Using fftcommand, DFT is calculated.
Step 5: Calculate the magnitude and phase responses.
Step 6: Plot the magnitude and phase responses.
Step 6: Terminate the process.
PROGRAM:
xn=[1 1 1 0 0 0 0 0];
N=8;
Xk=fft(xn,N);
disp('DFT of the given sequence is');
disp(Xk);
%computation of magnitude response of X(k)
subplot(2,1,1);
z=abs(Xk);
disp('Magnitude response is');
disp(z);
stem(z);
grid;
title('plot of magnitude of X(k)');
xlabel('index k');
ylabel('magnitude');
%Enter the input x(n)
xn=[1 1 1 0 0 0 0 0];
N=8;
Xk=fft(xn,N);
disp('DFT of the given sequence is');
disp(Xk);
%computation ofphase response
subplot(2,1,2);
t=angle(Xk);
disp('Phase response is');
disp(t);
stem(t);
grid;
title('plot of phase of X(K)');
xlabel('index k');
ylabel('angle in radians');
OUTPUT:
FFT OF THE GIVEN SEQUENCE
[3.0000
1.7071 - 1.7071i
0 - 1.0000i 0.2929 + 0.2929i
0.2929 - 0.2929i
0 + 1.0000i
1.7071 + 1.7071i]
1.0000
Magnitude response is
[ 3.0000
2.4142
1.0000
0.4142
1.0000
0.4142
1.0000
2.4142 ]
Phase response is
[ 0 -0.7854 -1.5708
0.7854
0 -0.7854
1.5708
0.7854 ]
RESULT:
Thus the MATLAB programs for FFT for the given finite duration was generated using
FFT algorithm.
EX.NO:
DATE
DATE:
AIM
To write a MATLAB program to obtain Inverse Discrete Fourier Transform for the system
given in the form of finite duration sequence as follows Xk=[5 0 (1-j) 0 1 0 (1+j) 0 ]using FFT
algorithm. Also plot the magnitude and phase responses for the same.
APPARATUS REQUIRED:
HARD WARE: IBM PC (Or) Compatible PC
SOFTWARE: MATLAB 6.0 (Or) Higher version
THEORY:
COMPUTATION OF IDFT THROUGH FFT:
The Inverse Discrete Fourier Transform (IDFT) of the sequence X(k) of length N is defined as,
N-1
IDFT [X (k)] = x (n) = 1/N X(k) e j2nk /N, n = 0,1,2,3(N-1) (1)
k=0
Taking the conjugate of equation (1) multiplying by N, we get
N-1
N. x*(n) = X*(k) e - j2nk /N,
n = 0,1,2,3(N-1) (2)
k=0
The R.H.S of equation (2) the DFT of the sequence x*(n) and may be computed using FFT
algorithm. The desired output sequence x(n) is obtained by complex conjugating the equation (2)
and dividing by N to give
N-1
x(n) = 1/N [ X*(k) e
k=0
- j2nk /N *
] , n = 0,1,2,3(N-1) ..(3)
In equation (3) the expression inside the brackets is same as the DFT computation of a sequence.
Hence in order to compute IDFT of X(k), the following procedure can be followed.
1.Take complex conjugate of X(k).
2. Compute the N-point DFT of X*(k) using radix 2 FFT.
3. Take complex conjugate of the output sequence of FFT.
4. Divide the sequence obtained in step 3 by N. The resultant sequence is x(n).
ALGORITHM:
Step 1: Start the program.
Step 2: Get the finite duration sequence X(k).
Step 3: Calculate the value of N.
Step 4: Using ifftcommand, IDFT is calculated.
Step 5: Calculate the magnitude and phase responses.
Step 6: Plot the magnitude and phase responses.
Step 7: Terminate the process
PROGRAM:
%computation of IFFT
%Enter the input X(k)
Xk=[5 0 (1-j) 0 1 0 (1+j) 0 ];
N=8;
xn=ifft(Xk,N);
disp('IFFT of the given sequence is');
disp(xn);
INPUT:
X(K) =[5 0 (1-j) 0 1 0
(1+j) 0 ]
OUTPUT:
IFFT of the given sequence is
[1.0000
0.7500
0.5000
0.2500
1.0000
0.7500
0.5000
0.2500]
RESULT:
Thus the MATLAB programs for IFFT for the given finite duration were executed.
EX.NO:
DATE :
A. DECIMATION USING MATLAB
AIM:
To write a MATLAB program to decimate the given sinusoidal sequence for a down sampling
factor of M = 2.
APPARATUS REQUIRED:
HARD WARE: IBM PC (Or) Compatible PC
SOFTWARE:
THEORY:
The process of reducing the sampling rate of a signal is called decimation
(Sampling rate compression). Decimation is also known as down sampling.
The decimated signal is given by
y(n)= x(Mn) , where M be the integer sampling rate reduction factor.
The general representation of decimation process can be
x(n)
h(n)
w(n)
F
M
F
Decimator
y(n)
F1=F/M
ALGORITHM:
Step 1: Start the program.
Step 2: Get the length of the sinusoidal input signal.
Step 3: Get the down sampling factor M.
Step 4: Get the frequency of sinusoidal signal.
Step 5: Compute the decimated signal using decimate command.
Step 6: Plot the output sequence.
Step 7: Terminate the process.
PROGRAM:
%Decimation process
%Get the length of sinusoidal signal
N=input('Enter the length of sinusoidal signal :');
n=0:N-1;
%Get the value of Down sampling factor
M=input('Enter the Down-sampling factor :');
n=0:N-1;
%Generate the input sequence
f=input('Enter the input signal frequency :');
x=sin(2*pi*f*n);
%Generate the decimated output sequence
y=decimate(x,M,'fir');
%plot the input sequence
figure(1);
stem(n,x(1:N));
title('input sequence');
xlabel('time index n--->');
ylabel('amplitude');
m=0:(N/M)-1;
figure(2);
stem(m,y(1:N/M));
title('Decimated output sequence');
xlabel('time index n--->');
ylabel('amplitude');
INPUT:
0.8
0.6
0.4
amplitude
0.2
-0.2
-0.4
-0.6
-0.8
-1
0
10
20
30
40
50
60
70
80
90
100
40
45
50
OUTPUT WAVEFORM
Decimated output sequence
1.5
amplitude
0.5
-0.5
-1
0
10
15
20
25
30
35
RESULT:
Thus the MATLAB program for decimate the given sinusoidal sequence for a down
sampling factor of M = 2 was generated and executed successfully.
EX.NO:
DATE :
B.INTERPOLATION USING MATLAB
AIM:
To write a MATLAB program to interpolate the given sinusoidal sequence for a
Up sampling factor of L = 3.
APPARATUS REQUIRED:
HARD WARE: IBM PC (Or) Compatible PC
SOFTWARE:
THEORY:
The process of increasing the sampling rate of a signal is called Interpolation (Sampling rate
expansion). Interpolation is also known as up sampling.
The interpolated signal is given by
y(n)= x(n/L) , where L be the integer sampling rate increasing factor.
The general representation of interpolation process can be
x(n)
w(n)
h(n)
y(n)
F1=LF
ALGORITHM:
Step 1: Start the program.
Step 2: Get the length of the sinusoidal input signal.
Step 3: Get the Up sampling factor L.
Step 4: Get the frequency of sinusoidal signal.
Step 5: Compute the interpolated signal using interp command.
Step 6: Plot the output sequence.
Step 7: Terminate the process.
F1
PROGRAM:
%interpolation process
%Get the length of sinusoidal signal
N=input('Enter the length of sinusoidal signal:');
n=0:N-1;
%Get the value of Up sampling factor
L=input('Enter the Up-sampling factor:');
%Generate the input sequence
f=input('Enter the input signal frequency:');
x=sin(2*pi*f*n);
%Generate the interpolated output sequence
y=interp(x,L);
%plot the input sequence
figure(1);
stem(n,x(1:N));
title('input sequence');
xlabel('time index n--->');
ylabel('amplitude');
figure(2);
m=0:(N*L)-1;
stem(m,y(1:N*L));
title('Interpolated output sequence');
xlabel('time index n--->');
ylabel('amplitude');
INPUT:
Enter the length of sinusoidal signal: 50
Enter the Up-sampling factor: 3
Enter the input signal frequency: 0.045
OUTPUT
INPUT WAVEFORM
OUTPUT WAVEFORM
Interpolated output sequence
1.5
amplitude
0.5
-0.5
-1
-1.5
0
50
100
time index n--->
150
RESULT:
Thus the MATLAB program for interpolate the given sinusoidal sequence for a Up
sampling factor of L = 3 was generated and executed successfully
EX.NO:
DATE :
AIM:
To write a MATLAB program to obtain the linear convolution between two finite duration
sequences x(n) and h(n).
APPARATUS REQUIRED:
HARD WARE: IBM PC (Or) Compatible PC
SOFTWARE: MATLAB 6.0 (Or) Higher version
THEORY:
Convolution is a powerful way of characterizing the input-output relationship of time
invariant linear systems. Convolution finds its application in processing signals especially analyzing
the output of the system.
The response or output y(n) of a LTI system for any arbitrary input is given by convolution
of input and the impulse response h(n) of the system.
(1)
k=
If the input has L samples and the impulse response h(n) has M samples then the output
sequence y(n) will be a finite duration sequence consisting of L+ M-1 samples. The convolution
results in a non-periodic sequence. Hence this convolution is also called aperiodic convolution.
The convolution relation of equation (1) can also be expressed as
y(n) = x(n) *h(n) = h(n) * x(n)
where the symbol * indicates convolution operation.
ALGORITHM:
Step 1: Start the program.
Step 2: Get the sequence x(n).
Step 3: Get the range of the sequence x(n).
Step 4: Get the sequence h(n).
Step 5: Get the range of the sequence h(n)..
Step 6: Find the convolution between the sequences x(n) and h(n) using conv command.
Step 7: Plot the convoluted sequence y(n).
Step 8: Terminate the process.
PROGRAM:
%program to find linear convolution of two finite duration sequences
clf;
seq1=input('Enter the input sequence x(n)');
n1=input('Enter the range of x(n)');
subplot(2,1,1);
stem(n1,seq1);
title('input sequence x(n)');
xlabel('time');
ylabel('amplitude');
%Get the second sequence h(n)
seq2=input('Enter the input sequence h(n)');
n2=input('Enter the range of h(n)');
subplot(2,1,2);
stem(n2,seq2);
title('impulse response sequence h(n)');
xlabel('time');
ylabel('amplitude');
outseq=conv(seq1,seq2);
n=(min(n1)+min(n2)):1:(max(n1)+max(n2));
figure(2);
stem(n,outseq);
title('output sequence y(n)');
xlabel('time');
ylabel('amplitude');
disp('convoluted output:');
disp(outseq);
INPUT:
Enter the input sequence x(n)[ 1 2 3 4]
Enter the range of x(n)0:3
Enter the input sequence h(n)[4 3 2 1]
Enter the range of h(n)-1:2
OUTPUT: Convoluted output: 4 11
20
30
20
11
amplitude
0
0
0.5
1.5
2.5
1.5
time
impulse response sequence h(n)
4
amplitude
0
-1
-0.5
0.5
time
output sequence
30
25
amplitude
20
15
10
0
-1
2
time
RESULT:
Thus the MATLAB program for Linear convolution was generated and their
responses were plotted in discrete time domain successfully.
EX.NO:
DATE :
AIM:
To write a MATLAB program to obtain the circular convolution between two finite duration
sequences x(n) and h(n).
APPARATUS REQUIRED:
THEORY:
Convolution is a powerful way of characterizing the input-output relationship of time
invariant linear systems. Convolution finds its application in processing signals especially analyzing
the output of the system.
The response or output y(n) of a LTI system for any arbitrary input is given by convolution
of input and the impulse response h(n) of the system.
(1)
k=
If the input has L samples and the impulse response h(n) has M samples then the output
sequence y(n) will be a finite duration sequence consisting of L+ M-1 samples. The convolution
results in a non-periodic sequence. Hence this convolution is also called aperiodic convolution.
The convolution relation of equation (1) can also be expressed as
y(n) = x(n) *h(n) = h(n) * x(n)
where the symbol * indicates convolution operation.
ALGORITHM:
Step 1: Start the program.
Step 2: Get the sequence x(n).
Step 3: Get the range of the sequence x(n).
Step 4: Get the sequence h(n).
Step 5: Get the range of the sequence h(n)..
Step 6: Find the convolution between the sequences x(n) and h(n) using conv command.
Step 7: Plot the convoluted sequence y(n).
Step 8: Terminate the process.
PROGRAM:
%program to find the circular convolution
seq1=input('enter the input sequence: ');
N1=length(seq1);
k1=0:N1-1;
subplot(2,1,1);
stem(k1,seq1);
title('first sequence ');
xlabel('time');
ylabel('amplitude');
seq2=input('enter the second sequence: ');
N2=length(seq2);
k2=0:N2-1;
subplot(2,1,2);
stem(k2,seq2);
title('first sequence ');
xlabel('time');
ylabel('amplitude');
seq3=[seq2(1) fliplr(seq2(2:N1))];
seq4=seq1.*seq3;
seq(1)=sum(seq4);
N=N1;
for n=1:N-1;
seq5=[seq3(N) seq3(1:N-1)];
seq6=seq5.*seq1;
seq(n+1)=sum(seq6);
seq3=seq5;
end
disp('circular convolution sequence');
disp(seq);
figure(2);
stem(k2,seq);
title('circular convolution sequence ');
xlabel('time');
ylabel('amplitude');
INPUT:
enter the input sequence: [1 2 3 4]
enter the second sequence: [5 6 7 8]
OUTPUT: circular convolution sequence:
INPUT SEQUENCE
OUTPUT SEQUENCE
66
68
66
60
RESULT:
Thus the MATLAB program for Circular convolution
responses were plotted in discrete time domain successfully.
was
generated and
their
EX.NO:
DATE :
AIM:
To write a MATLAB program for the design of FIR Low Pass Filter (LPF) for the given cut
off frequency using Hamming window. Also plot the magnitude and log magnitude responses for
the same.
APPARATUS REQUIRED:
HARD WARE: IBM PC (Or) Compatible PC
SOFTWARE: MATLAB 6.0 (Or) Higher version
THEORY:
The filters designed by using finite number of samples of impulse response are called
FIR filters. These finite number of samples are obtained from the infinite duration desired impulse
response hd(n). Here hd(n)is the inverse Fourier transform of Hd(), where Hd() is the ideal
(desired) frequency response. The various methods of designing FIR filters are (i). Fourier series
method, (ii). Window method, (iii). Frequency Sampling method, (iv) Optimal filter design method.
Here we discuss about window method only.
DESIGN OF FIR FILTERS USING WINDOWS:
The desired frequency response Hd(ej) of a filter is periodic in frequency and can be
expanded in a Fourier series. The resultant series is given by
After multiplying window sequejnce w(n) with Hed(n), we get a finite duration sequence
jh(n) that satisfies the desired magnitude respone,
h(n) = hd(n)(n)
=0
The frequency response H(ej) of the filter can be obtained by convolution of Hd(ej)) and
W(ej)
given by
= 0
otherwise
Sin (/2)
ALGORITHM:
Step 1: Start the program.
Step 2: Get the cutoff frequency.
Step 3: Get the value of N.
Step 4: Get the window function (n) for Hamming window.
Step 5: Design a linear phase FIR low pass filter using fir1 command.
Step 6: Compute the complex frequency response of digital transfer function at specified
frequency points using freqz command.
Step 7: Plot the magnitude response and log magnitude response.
Step 8: Terminate the process.
PROGRAM:
%Design of Low pass FIR Filter using Hanning window
%Get the cutoff frequency
wc=input('Enter the cut off frequency :');
%Get the order of the filter(N)
N=input('Enter the order of the filter :');
%calculation of filter co efficients
b=fir1(N,wc,hanning(N+1));
w=0:0.01:pi;
%compute the frequency response
h=freqz(b,1,w);
%plot the magnitude response of LPF
figure(1);
plot(w/pi,abs(h));
ylabel('magnitude');
xlabel('normalized frequency');
title('magnitude response of LPF');
%plot the log magnitude response of LPF
figure(2);
plot(w/pi,20*log10(abs(h)));
ylabel('magnitude in dB');
xlabel('normalized frequency');
title('Log magnitude response of LPF');
INPUT:
Enter the cut off frequency : 0.9
Enter the order of the filter : 25
OUTPUT:
magnitude response of LPF
1.4
1.2
magnitude
0.8
0.6
0.4
0.2
0
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
normalized frequency
magnitude in dB
-10
-20
-30
-40
-50
-60
0
0.1
0.2
0.3
0.4
0.5
0.6
normalized frequency
0.7
0.8
0.9
RESULT:
Thus the MATLAB program for the design of FIR LPF using Hamming window for the
given cut off frequency was designed and also magnitude and log magnitude responses for the same
were plotted successfully.
EX.NO:
DATE:
AIM:
To write a MATLAB program to design (i) Butterworth low pass digital IIR filter
(ii) Butterworth high pass digital IIR filter from the given specifications.
APPARATUS REQUIRED:
HARD WARE: IBM PC (Or) Compatible PC
SOFTWARE: MATLAB 6.0 (Or) Higher version
THEORY:
The filters designed by considering all the infinite samples of impulse response are
called IIR filters. IIR filters are of recursive type, whereby the present output sample depends on the
present input, past input samples and output samples.
DESIGN OF AN ANALOG BUTTERWORTH LOWPASS FILTER:
1. From the given specifications find the order of the filter N.
N log (/)
log (s /P)
Where
= (100.1s -1)1/2
= (100.1p-1)1/2
s-minimum stop band attenuation in positive dB
p-maximum pass band attenuation in positive dB
p-pass band frequency
s-stop band frequency
2. Round off it to the next higher integer.
3. Find the transfer function H (s) for c =1 rad/sec for the value of N.
4. Calculate the value of cutoff frequency c.
5. Find the transfer function H a (s) for the above value of c by
Substituting s s/ c in H (s).
DESIGN OF DIGITAL FILTERS FROM ANALOG FILTERS:
The most common technique used for designing IIR digital filters known as indirect method, involves first designing an analog prototype
filter and then transforming the prototype to a digital filter. For the given specifications of a digital filter, the derivation of the digital filter
transfer function requires three steps.
1. Map the desired digital filter specifications into those for an equivalent analog filter.
2. Derive the analog transfer function for the analog prototype.
3. Transform the transfer function of the analog prototype into an equivalent digital filter
transfer function.
The four most widely used methods for digitizing the analog filter into a digital filter include.
1 .Approximation of derivatives.
2. The impulse invariant transformation
3. The bilinear transformation
4. The matched z-transformation technique.
Z -1 +
1+ Z -1
where =
cos[(c1 + c )/ 2]
cos[(c1 - c )/ 2]
PROGRAM:
%Design of Butterworth IIR LPF
rp=input('Enter passband ripple :');
rs=input('Enter stopband ripple :');
fp=input('Enter passband frequency :');
fs=input('Enter stopband frequency :');
Fs=input('Enter sampling frequency :');
wp=2*(fp/Fs);
ws=2*(fs/Fs);
[N,wn]=buttord(wp,ws,rp,rs);
[b,a]=butter(N,wn,'low');
[hl,ol]=freqZ(b,a,512,Fs);
ml=20*log10(abs(hl));
%plot(1);
plot(ol/pi,ml);
xlabel('normalised frequency is ---->');
ylabel('gain in db --->');
title('butterworth lowpass filter');
INPUT:
Enter passband ripple :03
Enter stopband ripple :60
Enter passband frequency :40
Enter stopband frequency :150
Enter sampling frequency :1000
butterworth lowpass filter
50
-50
gain in db --->
-100
-150
-200
-250
-300
-350
0
20
40
60
80
100
120
140
160
PROGRAM:
% Design of Butterworth IIR HPF
rp=input('Enter passband ripple :');
rs=input('Enter stopband ripple :');
fp=input('Enter passband frequency :');
fs=input('Enter stopband frequency :');
Fs=input('Enter sampling frequency :');
wp=2*(fp/Fs);
ws=2*(fs/Fs);
[n,wn]=buttord(wp,ws,rp,rs);
[b,a]=butter(n,wn,'high');
[hh,oh]=freqZ(b,a,512,Fs);
mh=20*log10(abs(hh));
plot(oh/pi,mh);
xlabel('normalised frequency is ---->');
ylabel('gain in db --->');
title('butterworth highpass filter');
INPUT:
Enter passband ripple :03
Enter stopband ripple :60
Enter passband frequency :40
Enter stopband frequency :150
Enter sampling frequency :1000
OUTPUT:
butterworth highpass filter
20
-20
-40
gain in db --->
-60
-80
-100
-120
-140
-160
-180
0
20
40
60
80
100
120
140
160
RESULT:
Thus the MATLAB programs for the design of Butterworth LPF and HPF were designed
and also their magnitude responses were plotted successfully.
EX.NO:
DATE:
RESPONSE'
DATE :
AIM:
To write a MATLAB program to 'Decimation of polyphase decomposition sequence response'
APPARATUS REQUIRED:
HARD WARE: IBM PC (Or) Compatible PC
SOFTWARE:
THEORY:
The process of reducing the sampling rate of a signal is called decimation
(Sampling rate compression). Decimation is also known as down sampling.
The decimated signal is given by
y(n)= x(Mn) , where M be the integer sampling rate reduction factor.
The general representation of decimation process can be
x(n)
h(n)
w(n)
F
M
F
Decimator
y(n)
F1=F/M
ALGORITHM:
Step 1: Start the program.
Step 2: Get the length of the sinusoidal input signal.
Step 3: Get the down sampling factor M.
Step 4: Get the frequency of sinusoidal signal.
Step 5: Compute the decimated signal using decimate command.
Step 6: Plot the output sequence.
Step 7: Terminate the process.
PROGRAM:
%'Decimation of polyphase decomposition sequence response'
clear all;
clc;
close all;
x=input('enter the input sequence');
h=input('enter the FIR filter coefficients');
M=input('enter the decimation factor');
N1=length(x);
N=0:1:N1-1;
subplot(2,1,1);
stem(N,x);
xlabel('time');
ylabel('amplitude');
Title('X sequence response');
N2=length(h);
n=0:1:N2-1;
subplot(2,1,2);
stem(n,h);
xlabel('time');
ylabel('amplitude');
title('H sequence response');
H=length(h);
P=floor((H-1)/M)+1;
r=reshape([reshape(h,1,H),zeros(1,P*M-H)],M,P);
X=length(x);
Y=floor((X+H-2)/M)+1;
U=floor((X+M-2)/M)+1;
R=zeros(1,X+P-1);
for m=1:M
R=R+conv(x(1,:),r(m,:));
end
Disp(R);
N=length(R);
n=0:1:N-1;
figure(2);
stem(n,R);
xlabel('time');
ylabel('amplitude');
title('Decimation of polyphase decomposition sequence response');
INPUT:
Enter the input sequence:[1 2 3 4]
Enter the FIR filter coefficients [1 1 1 1]
Enter the decimation factor 3
OUTPUT: 3
11
15
INPUT WAVEFORM
OUTPUT WAVEFORM
RESULT:
Thus the MATLAB program for decimate the given sinusoidal sequence for a down
sampling factor of M = 2 was generated and executed successfully.
KIT EXPERIMENTS
EX. NO:
GENERATION OF SIGNALS
DATE:
AIM:
To write a assembly program to generate a following standard input signals Sinusoidal
signal, Saw tooth wave, Square wave and triangle wave
PROGRAM
;SINEWAVE GENERATION.
;*********************
FREQ .set 1
LENGTH .SET 360
AMPLITUDE .set 5
TEMP .set 0
TEMP1 .set 1
.mmregs
.text
START:
LDP #100H
SPLK #0C100H,TEMP ;load start address of table
lar AR2,#LENGTH
CONT:
LACC TEMP
;load address of sine value
TBLR TEMP1
;read sine data to TEMP1
LT TEMP1
MPY #AMPLITUDE
PAC
SACL TEMP1
OUT TEMP1,4
;send sine data to DAC
LACC TEMP
ADD #FREQ
;increase table value
SACL TEMP
;store it
MAR *,AR2
BANZ CONT,*b
START
.end
;****************************************************************************
;SAWTOOTH WAVEFORM GENERRATION
;****************************************************************************
.MMREGS
.TEXT
START:
LDP #120H
LACC #0H ;change lower amplitude
SACL 0
LOOP: LACC 0
OUT 0,04H
ADD #05h ;change frequency
SACL 0
SUB #0FFFh ;change upper amplitude
BCND LOOP,LEQ
B
START
.END
;****************************************************************************
;****************************************************************************
;square waveform generation.
;****************************************************************************
.mmregs
.text
start:
ldp #100h
lacc #0fffh ;change this value for amplitude.
loop: sacl 0
rpt #0ffh ;change this value for frequency.
out 0,04
;address for dac.
cmpl
b
loop
.end
;****************************************************************************
;triangle
AMPLITUDE .SET 5
FREQ .SET 175
TEMP .SET 0
;
.mmregs
.text
START:
LDP #100H
splk #0,TEMP
CONT1:
lar AR2,#FREQ
CONT:
out TEMP,4
LACC TEMP
ADD #AMPLITUDE
SACL TEMP
MAR *,AR2
BANZ CONT,*LAR AR2,#FREQ
CONTx:
OUT TEMP,4
LACC TEMP
SUB #AMPLITUDE
SACL TEMP
MAR *,AR2
BANZ CONTx
B
CONT1
.end
RESULT:
Thus the Assembly programs for sinusoidal signal saw tooth, square wave triangle w were
plotted in discrete and continuous time domain successfully.
EX. NO:
DATE:
AIM:
To write a assembly program to obtain the linear convolution between two finite duration
sequences x(n) and h(n).
PROGRAM:
;***************************************************************************
;
LINEAR CONVALUTION
;***************************************************************************
.mmregs
.text
START:
LDP #02H
LAR AR1,#8100H ; x(n) datas
lar ar0,#08200H ;h(n) datas
LAR AR3,#8300H ;y(n) starting
LAR AR4,#0007 ;N1+N2-1
;to fold the h(n) values
lar ar0,#08203H
lacc #0c100h
mar *,ar0
rpt #3
tblw *;padding of zerros for x(n) values
lar ar6,#8104h
mar *,ar6
lacc #0h
rpt #3h
sacl *+
;convalution operation starts
LOP: MAR *,AR1
LACC *+
SACL 050H ;starting of the scope of multiplication
LAR AR2,#0153H ; end of the array, to be multiplied with h(n) {150+N1-1}
MAR *,AR2
ZAP
RPT #03H ;N1-1 times so that N1 times
MACD 0C100H,*APAC
;to accmulate the final product sample
MAR *,AR3
SACL *+
MAR *,AR4
BANZ LOP,*H:
B H
;INPUT ( x(n) )
;8100 - 1
;8101 - 3
;8102 - 1
;8103 - 3
;INPUT ( h(n) )
; 8200 - 0
; 8201 - 1
; 8202 - 2
; 8203 - 1
;OUTPUT ( y(n) )
; 8300 - 1
; 8301 - 5
; 8302 - 8
; 8303 - 8
; 8304 - 7
; 8305 - 3
; 8306 - 0
RESULT:
Thus the Assembly programs for linear convolution was successfully verified
EX. NO:
DATE:
AIM:
To write a assembly program to obtain the FFT
PROGRAM
;*********************************************************
;
FFT(4 POINT)
;*********************************************************
IN
.set 8010H
BITREV .set 8020H
REAL .set 8040H
IMG .set 8050H
.MMREGS
.TEXT
LDP #100H
LAR AR1,#IN
LAR AR2,#BITREV
SPLK #2H,05H
LMMR INDX,#8005H
MAR *,AR2
RPT #3H
BLDD #IN,*BR0+
LAR AR2,#BITREV
LAR AR3,#8030H
LAR AR0,#1H
FFT1: MAR *,AR2
LACC *+
SACB
LT *+
MPY #1H
APAC
MAR *,AR3
SACL *+
LACB
SPAC
SACL *+,AR0
BANZ FFT1,*LAR AR3,#8030H
LAR AR4,#REAL
LAR AR5,#IMG
MAR *,AR3
LACC *
SACB
ADRK #2H
LT *MPY #1H
APAC
MAR *,AR4
SACL *
ADRK #2H
LACC #0H
MAR *,AR5
SACL *
ADRK #2H
LACB
SPAC
MAR *,AR4
SACL *LACC #0H
MAR *,AR5
SACL *-,AR3
LACC *,AR4
SACL *
ADRK #2H
SACL *,AR3
ADRK #2H
LT *
MPY #0FFFFH
MAR *,AR5
SPL *,AR3
LT *
MPY #1H
MAR *,AR5
ADRK #2H
SPL *
H:
B
H
;INPUT:
;
8010-0001
;
8011-0001
; 8012-0000
; 8013-0000
;BIT_REV:
;
8020-0001
;
8021-0000
; 8022-0001
; 8023-0000
;FFT1:
;
8030-0001
;
8031-0001
; 8032-0001
; 8033-0001
;REAL:
;
8040-0002
;
8041-0001
; 8042-0000
; 8043-0001
;IMG:
;
8050-0000
;
8051-FFFF
; 8052-0000
; 8053-0001
RESULT:
Thus the Assembly programs for FFT was successfully verified
EX. NO:
AIM: DATE:
To write a assembly program to obtain the FIR design.
PROGRAM
* FIR Filter, Created by Filter Design Package,
* (c) 1996, Vi Microsystems Pvt. Ltd.,
*
* Approximation type: Window design - Blackmann Window
* Filter type: Lowpass filter
* Filter Order: 52
* Cutoff frequency in KHz = 3.000000
.mmregs
.text
B
START
CTABLE:
.word 0FFE7H
.word 0FFD3H
.word 0FFC6H
.word 0FFC4H
.word 0FFD0H
.word 0FFECH
.word 018H
.word 051H
.word 08CH
.word 0B9H
.word 0C2H
.word 092H
.word 01AH
.word 0FF5FH
.word 0FE78H
.word 0FD9AH
.word 0FD10H
.word 0FD30H
.word 0FE42H
.word 071H
.word 03B5H
.word 07CAH
.word 0C34H
.word 01054H
.word 01387H
.word 01547H
.word 01547H
.word 01387H
.word 01054H
.word 0C34H
.word 07CAH
.word 03B5H
.word 071H
.word 0FE42H
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
0FD30H
0FD10H
0FD9AH
0FE78H
0FF5FH
01AH
092H
0C2H
0B9H
08CH
051H
018H
0FFECH
0FFD0H
0FFC4H
0FFC6H
0FFD3H
0FFE7H
*
*
Move the Filter coefficients
*
from program memory to data memory
*
START:
MAR *,AR0
;This block moves the filter coefficient from pgm memory to
data memory.
LAR AR0,#0200H
RPT #33H
BLKP CTABLE,*+
SETC CNF
* Input data and perform convolution
ISR: LDP #0AH
LACC #0
SACL 0
OUT 0,05
IN
0,06H
LAR AR7,#0
MAR *,AR7
BACK:
BANZ BACK,*IN
0,4
NOP
NOP
NOP
NOP
MAR *,AR1
LAR AR1,#0300H
LACC 0
AND #0FFFH
SUB #800H
SACL *
LAR AR1,#333H
MPY #0
ZAC
RPT #33H
MACD
0FF00H,*;CONVOLUTION OPERATION
APAC
LAR AR1,#0300H
SACH *
LACC *
ADD #800h
SACL *
OUT *,4
LACC #0FFH
SACL 0
OUT 0,05
NOP
B
ISR
.end
OUTPUT:
RESULT
Thus the Assembly programs for FIR design was successfully verified
EX. NO:
DATE:
AIM:
To write a assembly program to obtain the IIR design.
PROGRAM:
.MMREGS
.TEXT
TEMP .SET 0
INPUT .SET 1
T1
.SET 2
T2
.SET 3
T3
.SET 4
;
K
.SET 315eh
M
.SET 4e9fh
;cut-off freq is 1Khz. = Fc
;sampling frequency is 100 s (ie) 0.1ms.
; a = 2 * (355/113) * 1000 = 6283.18/1000 = 6.28 ;; divide by 1000 for secs
; K = aT/(1+aT) = 6.28*0.1 / (6.28*0.1+1) = 0.3857
; M = 1/(1+aT) = 1 / (6.28*0.1+1) = 0.61425
;convert to Q15 format
; K = K * 32767 = 12638.23 = 315Eh
; M = M * 32767 = 20127.12 = 4E9Fh
;Sampling Rate is 100 s & Cut off Frequency is 1 Khz
LDP #100H
LACC #0
SACL T1
SACL T2
SACL TEMP
OUT TEMP,4
;CLEAR DAC BEFORE START TO WORK
LOOP:
LACC #0
SACL TEMP
OUT TEMP,5
;OUTPUT LOW TO DAC2 TO CALCULATE TIMING
;
IN TEMP,06
;SOC
;
LAR AR7,#30h
;CHANGE VALUE TO MODIFY SAMPLING FREQ.
;sampling rate 100 s.
MAR
*,AR7
BACK:
BANZ
BACK,*;
IN
INPUT,4
;INPUT DATA FROM ADC1
NOP
NOP
;
LACC INPUT
AND #0FFFH
SUB #800h
SACL INPUT
;
LT
INPUT
MPY #K
PAC
SACH T1,1
;;;CALL MULT ----MULTIPLICATION TO BE DONE WITH K
;;RESULT OF MULT IN T1
;
LT T2
;PREVIOUS RESULT IN T2
MPY #M
PAC
SACH T3 ,1
;;;CALL MULT ----MULTIPLICATION TO BE DONE WITH M
;;RESULT OF MULT IN T3+
;
LACC T1
ADD T3
SACL T2
ADD #800h
SACL TEMP
OUT TEMP,4
;OUTPUT FILTER DATA TO DAC1
;
LACC #0FFH
SACL TEMP
OUT TEMP,5
;OUTPUT HIGH TO DAC2 TO CALCULATE TIMING
;
B
LOOP
OUTPUT:
butterworth highpass filter
20
-20
-40
gain in db --->
-60
-80
-100
-120
-140
-160
-180
0
20
40
60
80
100
120
140
160
RESULT
Thus the Assembly programs for IIR design was successfully verified