Experiment 1
Waveform Generation and Digital Filter Design and Analysis in Time
and Frequency Domains Using Matlab
Objectives:
1- Generation and analysis of different basic signals in time and frequency domain.
2- Design and analysis of typical FIR and IIR digital filters.
3- Filters application and implementation.
Lab Equipments:
1- PC with Matlab software installed.
2- Headphone.
Description:
In this experiment, we will use signal processing toolbox commands and analysis tools in
Matlab to visualize signals in time and frequency domains, compute FFTs for spectral
analysis of signals and filters, design FIR and IIR filters. Most toolbox functions require
you to begin with a vector representing a time base. Consider generating data with a 1000
Hz sample frequency, for example. An appropriate time vector is t = (0:0.001:1)';where
the MATLAB colon operator creates a 1001-element row vector that represents time
running from 0 to 1 s in steps of 1 ms. The transpose operator (') changes the row vector
into a column; the semicolon (;) tells MATLAB to compute, but not display the result.
Given t, you can create a sample signal y consisting of two sinusoids, one at 50 Hz and
one at 120 Hz with twice the amplitude. y = sin(2*pi*50*t) + 2*sin(2*pi*120*t);. You
may also generate discrete-time signals by first generating a sample axis using the
command n = (0:1:1024);. Then, to generate a sinusoidal signal sampled at twice the
Nyquist rate (or a signal that has a frequency that is one forth the sampling frequency),
use the command: X=cos(n*pi/2);. You may plot the signal in the time domain using the
command: plot (n,X). Since MATLAB is a programming language, an endless variety of
different signals is possible. Here are some statements that generate several commonly
used sequences, including the unit impulse, unit step, and unit ramp functions: t =
(0:0.001:1)';
y = [1; zeros(99,1)]; % impulse
y = ones(100,1); % step (filter assumes 0 initial cond.)
y = t; % ramp
Some applications, however, may need to import data from outside MATLAB. To load
data from an ASCII file or MAT-file, use the MATLAB load command. You may also
use this command to load wave files.
The single sided amplitude spectrum of a signal can be evaluated using the FFT function
which computes the Fast Fourier Transform. A simple Matlab function named
single_sided_amplitude_spectrum was written for this purpose. This function is stored in
the directory C:\DSPLaboratory. To calculate and plot single sided amplitude spectrum of
the signal Y sampled at FS frequency, type the command: