Date post: | 02-Apr-2018 |
Category: |
Documents |
Upload: | abhiroop-verma |
View: | 213 times |
Download: | 0 times |
of 39
7/27/2019 DSP_FILE
1/39
7/27/2019 DSP_FILE
2/39
EXPRIMENT NO. 1(A)
AIM :: TO GENERATE BASIC CONTINEOUS TIME SIGNALS ( SINE, UNIT STEP AND
UNIT RAMP).
THEORY ::
A continuous signal or a continuous-time signal is a varying quantity (a signal)
whose domain, which is often time, is a continuum (e.g., a connected interval of
the reals). That is, the function's domain is an uncountable set. The function itself
need not be continuous. To contrast, a discrete time signal has
a countable domain, like the natural numbers.
A signal of continuous amplitude and time is known as a continuous time signal or
an analog signal. This (a signal) will have some value at every instant of time. The
electrical signals derived in proportion with the physical quantities such as
temperature, pressure, sound etc. are generally continuous signals. The other
examples of continuous signals are sine wave, cosine wave, triangular wave etc.
Some of the continuous signals.
MATLAB CODE ::
clc;
clear all;
close all;
t=0:0.01:5;
f=2;
y=sin(2*pi*f*t);
subplot(3,1,1);
plot(t,y);
title('sin wave');
ylabel('y(t)');
7/27/2019 DSP_FILE
3/39
xlabel('t');
z= ones(1,501);
subplot(3,1,2);
plot(t,z);
title('unit step');
ylabel('z(t)');
xlabel('t');
x= t;
subplot(3,1,3);
plot(t,x);
title('ramp signal');
ylabel('x(t)');
xlabel('t');
7/27/2019 DSP_FILE
4/39
OUTPUT WAVEFORM ::
RESULT :: the program for BASIC SIGNAL GENERATION is written using MATLAB
and verified.
7/27/2019 DSP_FILE
5/39
EXPRIMENT NO. 1(B)
AIM :: TO GENERATE BASIC DISCRETE TIME SIGNALS ( SINE, UNIT STEP AND
UNIT RAMP).
THEORY ::
A discrete signal or discrete-time signal is a time series consisting of
a sequence of qualities. In other words, it is a type series that is a function over
a domain of discrete integral.
Unlike a continuous-time signal, a discrete-time signal is a function of a
continuous argument; however, it may have been obtained by sampling from a
continuous-time signal, and then each value in the sequence is called a sample.
When a discrete-time signal obtained by sampling a sequence corresponding to
uniformly spaced times, it has an associated sampling rate; the sampling rate is
not apparent in the data sequence, and so needs to be associated as a separate
data item.
MATLAB CODE ::
clc;clear all;
close all;
t=0:0.1:5;
f=2;
y=sin(2*pi*f*t);
subplot(3,1,1);
stem(t,y);
title('sin wave');
ylabel('y(n)');
7/27/2019 DSP_FILE
6/39
xlabel('n');
z= ones(1,51);
subplot(3,1,2);
stem(t,z);
title('unit step');
ylabel('z(n)');
xlabel('n');
x= t;
subplot(3,1,3);
stem(t,x);
title('ramp signal');
ylabel('x(n)');
xlabel('n');
OUTPUT WAVEFORM ::
7/27/2019 DSP_FILE
7/39
7/27/2019 DSP_FILE
8/39
7/27/2019 DSP_FILE
9/39
stem(n,y);
xlabel=('Time');
ylabel=('Amplitude');
title=('Impulse response');
grid on;
SAMPLE INPUT-
Enter the required legth of impulse response N=40
enter the coefficients of x(n),b=[0.8 -0.44 0.36 0.02]
enter the coefficients of y(n),a=[1 0.7 -0.45 -0.6]
FIGURE-
RESULT-The program for impulse response of an LTI system is written using
Matlab and verified.
7/27/2019 DSP_FILE
10/39
EXPRIMENT NO. 3
LINEAR CONVOLUTION
THEORY:
MATLAB CODE-
>> clear all;
>> close all;
>> a=input('enter the starting point of x[n]=');
enter the statring point of x[n]=0
>> b=input('enter the starting point of h[n]=');
enter the starting point of h[n]=-1
>> x=input('enter the co-efficients of x[n]=');
7/27/2019 DSP_FILE
11/39
enter the co-efficients of x[n]=[1 2 3]
>> h=input('enter the co-efficients of h[n]=');
enter the co-efficients of h[n]=[1 1 1]
>> y=conv(x,h);
>> subplot(3,1,1);
>> p=a:(a+length(x)-1);
>> stem(p,x);
>> grid on;
>> xlabel('Time');
>> ylabel('Amplitude');
>> title('INPUT x(n)');
>> subplot(3,1,2);
>> q=b:(b+length(h)-1);
>> stem(q,h);
>> grid on;
>> xlabel('Time');
>> ylabel('Amplitude');
>> title('IMPULSE RESPONSE h(n)');
>> subplot(3,1,3);
>> n=a+b:length(y)+a+b-1;
>> stem(n,y);
>> grid on;
7/27/2019 DSP_FILE
12/39
>> disp(y);
1 3 6 5 3
>> xlabel('Time');
>> ylabel('Amplitude');
>> title('linear convolution');
SAMPLE INPUT-
Enter the starting point of x(n)=0
Enter the starting point of h(n)=-1
Enter the co-efficients of x(n)=[1 2 3]
Enter the co-efficients of h[n]=[1 1 1]
FIGURE
7/27/2019 DSP_FILE
13/39
RESULT-
The program for linear convolution is written and verified.
7/27/2019 DSP_FILE
14/39
EXPRIMENT NO. 4
CIRCULAR CONVOLUTION
THEORY:
USER DEFINED FUNCTION
function y=crconc(x,h);
n1=length(x);
n2=length(h);
N=max(n1,n2);
x=[x,zeros(1,N-n1)];
h=[h,zeros(1,N-n2)];
for n=0:N-1;
7/27/2019 DSP_FILE
15/39
y(n+1)=0;
for k= 0:N-1;
j=mod(n-k,N);
y(n+1)=y(n+1)+x(k+1)*h(j+1);
end
end
MATLAB CODE-
clc;
clear all;
close all;
x=input('enter the co-efficients of x1[n]=');
h=input('enter the co-efficients of x2[n]=');
y=crconc(x,h);
subplot(3,1,1);
n=0:(length(x)-1)
stem(n,x);
grid on;
xlabel=('Time');
ylabel=('amplitude');
title=('x1[n]');
subplot(3,1,2);
7/27/2019 DSP_FILE
16/39
n=0:(length(h)-1)
stem(n,h);
grid on;
xlabel=('Time');
ylabel=('amplitude');
title=('x2[n]');
subplot(3,1,3);
n=0:(length(y)-1)
stem(n,y);
grid on;
disp(y);
xlabel=('Time');
ylabel=('amplitude');
title=('OUTPUT x3[n]');
SAMPLE INPUT
enter the co-efficients of x1[n]=[1 2 3]
enter the co-efficients of x2[n]=[1 2]
n =
0 1 2
n =
0 1
7/27/2019 DSP_FILE
17/39
1n =
0 1 2
7 4 7
FIGURE-
RESULT- Program for circular convolution is written using Matlab and verified.
7/27/2019 DSP_FILE
18/39
EXPRIMENT NO. 5
AIM :: TO WRITE A PROGRAME TO COMPUTE DISCRETE FOURIER TRANSFORM.
THEORY ::
In mathematics, the discrete Fourier transform (DFT) converts a finite list of
equally-spaced samples of a function into the list of coefficients of a finite
combination of complex sinusoids, ordered by their frequencies, that has those
same sample values. It can be said to convert the sampled function from its
original domain (oftentime or position along a line) to the frequency domain.
The input samples are complex numbers (in practice, usually real numbers), and
the output coefficients are complex too. The frequencies of the output sinusoidsare integer multiples of a fundamental frequency, whose corresponding period is
the length of the sampling interval. The combination of sinusoids obtained
through the DFT is therefore periodic with that same period. The DFT differs from
the discrete-time Fourier transform (DTFT) in that its input and output sequences
are both finite; it is therefore said to be the Fourier analysis of finite-domain (or
periodic) discrete-time functions.
The DFT is the most important discrete transform, used to perform Fourier
analysis in many practical applications. In digital signal processing, the function is
any quantity or signal that varies over time, such as the pressure of a sound wave,
a radio signal, or daily temperature readings, sampled over a finite time interval
(often defined by a window function). In image processing, the samples can be
the values of pixels along a row or column of a raster image. The DFT is also used
to efficiently solve partial differential equations, and to perform other operations
such as convolutions or multiplying large integers.
Since it deals with a finite amount of data, it can be implemented
in computers by numerical algorithms or even dedicated hardware. These
implementations usually employ efficient fast Fourier transform (FFT)algorithms; so much so that the terms "FFT" and "DFT" are often used
interchangeably. The terminology is further blurred by the (now rare)
synonym finite Fourier transform for the DFT, which apparently predates the term
"fast Fourier transform" but has the same initialism.
7/27/2019 DSP_FILE
19/39
MATLAB CODE ::
clc;
clear all;
close all;
N=input('Enter the value of N');x=input('Enter the input sequence X(n):');
t=0:N-1;
subplot(2,1,1);
stem(t,x);
xlabel('TIME');
ylabel('AMPLITUDE');
title('INPUT SIGNAL');
grid on;
y=fft(x,N)subplot(2,1,2);
stem(t,y);
xlabel('TIME');
ylabel('AMPLITUDE');
title('OUTPUT SIGNAL');
grid on;
OUTPUT ::
Enter the value of N5Enter the input sequence X(n):[1 3 5 7 9]
y =
25.0000 -5.0000 + 6.8819i -5.0000 + 1.6246i -5.0000 - 1.6246i -5.0000 - 6.8819i
WAVEFORM ::
7/27/2019 DSP_FILE
20/39
RESULT :: the program for DISCRETE FOURIER TRANSFORM is written using
MATLAB and verified.
7/27/2019 DSP_FILE
21/39
EXPRIMENT NO. 6
INVERSE DISCRETE FOURIER TRANSFORM
THEORY-
Given a sequence ofN samplesf(n), indexed by n = 0..N-1, the Discrete Fourier
Transform (DFT) is defined as F(k), where k=0..N-1:
F(k) are often called the 'Fourier Coefficients' or 'Harmonics'.
The sequencef(n) can be calculated from F(k) using the Inverse Discrete Fourier
Transform (IDFT):
In general, bothf(n) and F(k) are complex.
MATLAB CODE-
clc;
clear all;
close all;
N=input('enter the value of N=');
y=input('enter the sequence y[n]=');
t=0:N-1;
subplot(2,2,1);
7/27/2019 DSP_FILE
22/39
stem(t,y);
xlabel('TIME');
ylabel('APMLITUDE');
title('input signal');
grid on;
x=ifft(y,N);
subplot(2,1,2);
stem(t,x);
xlabel('TIME');
ylabel('APMLITUDE');
title('input signal');
grid on;
SAMPLE INPUT-
enter the value of N=4
enter the sequence y[n]=[10 -2+2i 2 -2-2i]
7/27/2019 DSP_FILE
23/39
FIGURE-
RESULT-
The program for IDFT is written using Matlab and verified.
7/27/2019 DSP_FILE
24/39
EXPERIMENT NO.7
AIM :: TO FIND Z-TRANSFORM OF GIVEN FUNCTION.
THEORY :: The z-transform is the discrete-time counterpart of the Laplace
transform. The Z-transform, like many integral transforms, can be defined as
either a one-sidedor two-sidedtransform.
Bilateral Z-transform
The bilateralor two-sidedZ-transform of a discrete-time signalx[n] is the formal
power seriesX(z) defined as
where n is an integer and z is, in general, a complex number:
whereA is the magnitude ofz,jis the imaginary unit, and is the complex
argument(also referred to as angle orphase) in radians.
Unilateral Z-transform
Alternatively, in cases wherex[n] is defined only for n 0, the single-sidedor
unilateralZ-transform is defined as
In signal processing, this definition can be used to evaluate the Z-transform of the
unit impulse response of a discrete-time causal system.
7/27/2019 DSP_FILE
25/39
MATLAB CODE ::
k = input('Number of frequency points = ');
num = input('Numerator coefficients = ');
den = input('Denominator coefficients = ');
w = 0:pi/(k-1):pi;
h = freqz(num, den, w);
plot(w/pi,real(h));grid
title('Real part')
xlabel('\omega/\pi');
ylabel('Amplitude')
subplot(2,2,2)
plot(w/pi,imag(h));grid
title('Imaginary part')
xlabel('\omega/\pi');
ylabel('Amplitude')
subplot(2,2,3)
plot(w/pi,abs(h));grid
title('Magnitude Spectrum')
xlabel('\omega/\pi');
ylabel('Magnitude')
subplot(2,2,4)
plot(w/pi,angle(h));grid
7/27/2019 DSP_FILE
26/39
title('Phase Spectrum')
xlabel('\omega/\pi');
ylabel('Phase, radians')
SAMPLE INPUT-
enter the value of N=4
enter the sequence y[n]=[10 -2+2i 2 -2-2i]
Number of frequency points = 4
Numerator coefficients = [1 2]
Denominator coefficients = [1 5 6]
FIGURE-
7/27/2019 DSP_FILE
27/39
RESULT-
The ztransform is plotted and verified using Matlab.
7/27/2019 DSP_FILE
28/39
EXPERIMENT NO.8
AIM :: TO GENERATE POLE-ZERO PLOT OF GIVEN TRANSFER FUNCTION.
THEORY::
In DSP, a polezero plot is a graphical representation of a rational transfer
function in the complex plane which helps to convey certain properties of the
system such as:
Stability Causal system / anticausal system Region of convergence (ROC) Minimum phase / non minimum phaseA pole-zero plot shows the location in the complex plane of the poles and zeros of
the transfer function of a dynamic system, such as a controller, compensator,
sensor, equalizer, filter, or communications channel. By convention, the poles of
the system are indicated in the plot by an X while the zeroes are indicated by a
circle or O.
A pole-zero plot can represent either a continuous-time (CT) or a discrete-time(DT) system. For a CT system, the plane in which the poles and zeros appear is
the s plane of the Laplace transform. In this context, the parameter s represents
the complex angular frequency, which is the domain of the CT transfer function.
For a DT system, the plane is the z plane, where z represents the domain of the Z-
transform.
MATLAB CODE-
clear all;
b=input('enter the numerator coefficients');
a=input('enter the denominator coefficients');
http://en.wikipedia.org/wiki/Rational_functionhttp://en.wikipedia.org/wiki/Transfer_functionhttp://en.wikipedia.org/wiki/Transfer_functionhttp://en.wikipedia.org/wiki/BIBO_stabilityhttp://en.wikipedia.org/wiki/Causal_systemhttp://en.wikipedia.org/wiki/Anticausal_systemhttp://en.wikipedia.org/wiki/Radius_of_convergencehttp://en.wikipedia.org/wiki/Minimum_phasehttp://en.wikipedia.org/wiki/Transfer_functionhttp://en.wikipedia.org/wiki/Dynamic_systemhttp://en.wikipedia.org/wiki/S_planehttp://en.wikipedia.org/wiki/Laplace_transformhttp://en.wikipedia.org/wiki/Complex_numberhttp://en.wikipedia.org/wiki/Angular_frequencyhttp://en.wikipedia.org/wiki/Z-transformhttp://en.wikipedia.org/wiki/Z-transformhttp://en.wikipedia.org/wiki/Z-transformhttp://en.wikipedia.org/wiki/Z-transformhttp://en.wikipedia.org/wiki/Angular_frequencyhttp://en.wikipedia.org/wiki/Complex_numberhttp://en.wikipedia.org/wiki/Laplace_transformhttp://en.wikipedia.org/wiki/S_planehttp://en.wikipedia.org/wiki/Dynamic_systemhttp://en.wikipedia.org/wiki/Transfer_functionhttp://en.wikipedia.org/wiki/Minimum_phasehttp://en.wikipedia.org/wiki/Radius_of_convergencehttp://en.wikipedia.org/wiki/Anticausal_systemhttp://en.wikipedia.org/wiki/Causal_systemhttp://en.wikipedia.org/wiki/BIBO_stabilityhttp://en.wikipedia.org/wiki/Transfer_functionhttp://en.wikipedia.org/wiki/Transfer_functionhttp://en.wikipedia.org/wiki/Rational_function7/27/2019 DSP_FILE
29/39
zplane(b,a);
SAMPLE INPUT-
enter the numerator coefficients[1 2]
enter the denominator coefficients[1 5 6]
FIGURE-
RESULT-The pole zero plot is drawn using Matlab.
7/27/2019 DSP_FILE
30/39
EXPRIMENT NO. 9(A)
DIGITAL BUTTERWORTH LOW PASS FILTER
THEORY-
The Butterworth filter is a type of signal processing filter designed to have as flat
a frequency response as possible in the passband. It is also referred to as
a maximally flat magnitude filter. It was first described in 1930 by the
British engineer Stephen Butterworth.
Butterworth stated that:
"An ideal electrical filter should not only completely reject the unwanted
frequencies but should also have uniform sensitivity for the wanted frequencies".
Such an ideal filter cannot be achieved but Butterworth showed that successively
closer approximations were obtained with increasing numbers of filter elements
of the right values. At the time, filters generated substantial ripple in the
passband, and the choice of component values was highly interactive.
Butterworth showed that a low pass filter could be designed whose cutoff
frequency was normalized to 1 radian per second and whose frequency response
(gain) was
where is the angular frequency in radians per second and n is the number
ofpoles in the filterequal to the number of reactive elements in a passive
filter.
MATLAB CODE-
>>clc;
>> clear all;
>> close all;
>> rp=input('enter the passband attenuation:');
http://en.wikipedia.org/wiki/Low_pass_filterhttp://en.wikipedia.org/wiki/Gainhttp://en.wikipedia.org/wiki/Angular_frequencyhttp://en.wikipedia.org/wiki/Pole_(complex_analysis)http://en.wikipedia.org/wiki/Pole_(complex_analysis)http://en.wikipedia.org/wiki/Angular_frequencyhttp://en.wikipedia.org/wiki/Gainhttp://en.wikipedia.org/wiki/Low_pass_filter7/27/2019 DSP_FILE
31/39
enter the passband attenuation:0.4
>> rs=input('enter the stopband attenuation:');
enter the stopband attenuation:30
>> wp=input('enter the passband frequency:');
enter the passband frequency:0.2*pi
>> ws=input('enter the stopband frequency:');
enter the stopband frequency:0.4*pi
>> [N,wn]=buttord(wp/pi,ws/pi,rp,rs);
>> [b,a]=butter(N,wn);
>> freqz(b,a);
SAMPLE INPUT
Enter the passband attenuation- 0.4
Enter the stopband attenuation- 30
Enter the passband frequency- 0.2*pi
Enter the stopband frequency- 0.4*pi
FIGURE-
7/27/2019 DSP_FILE
32/39
RESULT-
Magnitude and phase response of butterworth filter are verified.
7/27/2019 DSP_FILE
33/39
EXPRIMENT NO. 9(B)
BUTTERWORTH HIGH PASS FILTER
MATLAB CODE-
clc;
clear all;
close all;
rp=input('enter the passband attenuation:');
rs=input('enter the stopband attenuation:');
wp=input('enter the passband frequency:');
ws=input('enter the stopband frequency:');
[N,wn]=buttord(wp/pi,ws/pi,rp,rs);
[b,a]=butter(N,wn);
freqz(b,a);
SAMPLE INPUT-
enter the passband attenuation:0.4
enter the stopband attenuation:30
enter the passband frequency:0.6*PI
enter the passband frequency:0.6*pi
enter the stopband frequency:0.2*pi
FIGURE
7/27/2019 DSP_FILE
34/39
RESULT-
Magnitude and phase response of butterworth high pass filter is verified.
7/27/2019 DSP_FILE
35/39
EXPRIMENT NO. 9(C)
BUTTERWORTH BAND STOP FILTER
MATLAB CODE-
clc;
clear all;
close all;
rp=input('enter the passband attenuation:');
rs=input('enter the stopband attenuation:');
wp=input('enter the passband frequency:');
ws=input('enter the stopband frequency:');
[N,wn]=buttord(wp/pi,ws/pi,rp,rs);
*b,a+=butter(N,wn,stop);
freqz(b,a);
SAMPLE INPUT-
enter the passband attenuation:0.2
enter the stopband attenuation:20
enter the passband frequency:[0.1*pi,0.5*pi]
enter the stopband frequency:[0.2*pi,0.4*pi]
7/27/2019 DSP_FILE
36/39
FIGURE
RESULT-
Magnitude and phase response of butterworth band stop filter is verified.
7/27/2019 DSP_FILE
37/39
EXPRIMENT NO. 9(D)
BUTTERWORTH BAND PASS FILTER
MATLAB CODE-
clc;
clear all;
close all;
rp=input('enter the passband attenuation:');
rs=input('enter the stopband attenuation:');
wp=input('enter the passband frequency:');
ws=input('enter the stopband frequency:');
[N,wn]=buttord(wp/pi,ws/pi,rp,rs);
[b,a]=butter(N,wn);
freqz(b,a);
SAMPLE INPUT-
enter the passband attenuation:.2
enter the stopband attenuation:20
enter the passband frequency:[0.2*pi,0.4*pi]
enter the stopband frequency:[0.1*pi,0.5*pi]
7/27/2019 DSP_FILE
38/39
FIGURE
RESULT-
Magnitude and phase response of butterworth band pass filter is verified.
7/27/2019 DSP_FILE
39/39