Vous êtes sur la page 1sur 13

Digital Signal Processing

LAB MANUAL

Prepared By: Sidra Minhas

TABLE OF CONTENTS

S No.

Title Instructions

Page No. 2 3 4 5 6 7 8 9 10 11 12

1 2 3 4 5 6 7 8 9 10

Continuous Time & Discrete Time Signal synthesis and plotting Algebraic operations on signals Signal indexing Convolution Signal Filtering Using FIR Filters Frequency Domain Representation of Signals using Fast Fourier Transform Graphical User Interface Hardware Interface I: Microphone Hardware Interface I: Digital Camera MATLAB Simulink

INSTRUCTIONS:
Digital signal processing (DSP) is the mathematical manipulation of an information signal to modify or improve it in some way. The best software available for such mathematical operations is MATLAB. In this course MATLAB 2009 has been used to implement, test and verify signal processing algorithms and theory. This manual aims to provide an advanced insight to signal processing using MATLAB. It is requested to the students to make a separate .m file for each lab exercise. Attach appropriate screen shots and images accompanying the results.

LAB 1

OBJECTIVE: Continuous Time & Discrete Time Signal synthesis and plotting INTRODUCTION: In real life, everything is continuous i.e. It can be divided into infinite many items. Similarly, real life signals are continuous in time i.e. they can be described over infinite divisions of time. CT signals carry large amounts of data. Therefore, CT signals need to be discretized. A discrete time signal has defined values on equal intervals of time. A CT signal can be converted to DT signal using sampling. The difference between CT and DT signals lie in sampling. The following experiments will demonstrate the effect of sampling interval.

TASK 1: 1. Plot the continuous time signal x(t)= sin(2t), 0 t 2 2. Sample x(t) with the sampling period TS=0.2, and print the values of the sampled result X(n) 3. Plot the sampled result X(n). Use black squares as markers and turn on grid 4. Save the figure as PDF TASK 2: Plot the following signals: 1. Y= (sin(wL/2)) / (L sin(w/2)) for L =10 and -2 < w < 2

LAB 2 OBJECTIVE: Algebraic operations on signals INTRODUCTION: Continuous Time signals are converted to discrete time signals for ease of computation and reservation of resources. Points by point algebraic operations are easier to implement. Signals can be added, subtracted, multiplied and divided. The following exercise demonstrates the algebraic manipulation of signals. TASK 1: 1. Plot the following CT signals for t = 0 to 10 x1(t) = 4e t/5 x2(t) = sin (2ft + /2) where f = 4 Hz u(t) = x1(t) x2(t) v(t) = x1(t) /x2(t) w(t) = u(t) +v(t) y(t) =u(t) v(t)

TASK 2: 1. Plot the following DT signals for n = 0 to 10 x3[n] = 2 (0.8)n x4[n] = sin(2n/N) where N = 10 u[n] = x3[n] x4[n] v[n] = x3[n] /x4[n] w[n] = x3[n] +x4[n] y[n] = u[n] v[n]

LAB 3 OBJECTIVE: Signal indexing INTRODUCTION: A signal is sum of samples of the signal. Individual samples can be accessed in MATLAB through their indexes. Maximum and minimum values of signals are of special interest that can be located easily. Similarly a range of values can also be extracted. The following exercise demonstrates the use of find, max and min instructions of MATLAB.

1. Evaluate a sine wave (y = sin(x)) at 1,000 points (x) between 0 and 2*pi. 2. Whats the value at a. Index 55 b. Indices 100 through 110 3. Find the index of a. the minimum value, b. the maximum value, and c. values between -0.001 and 0.001

LAB 4

OBJECTIVE: Implement discrete time convolution. Use of conv() and write user defined functions. INTRODUCTION: Convolution is an operation between two signals, resulting in a third signal. Convolution is an operation between the input signal to a system, and its impulse response, resulting in the output signal. In discrete time, convolution of two signals involves summing the product of the two signals where one of the signals is flipped and shifted . Its mathematical representation is as following:

TASK 1: 1. Create and display the following discrete time signals: X = [-1 0 1 2 3 4] Y = [-1 -2 3] 2. Using the inbuilt MATLAB function, create a convolved signal Z= Y*Y i.e. convolution of the above signals. 3. Display the signal Z. Be clear regarding the indexes. 4. Verify that X*Y = Y*X

TASK 2: 1. Now convolve the signal X and Y without using the inbuilt function. i.e. Write your own function of convolution.

LAB 5 OBJECTIVE: To filter a signal using averaging filter. INTRODUCTION: Filtering is a concept used to remove unwanted features from a signal especially noise. The most simple and easiest way of noise removal from a signal is applying a running averaging filter. The basic filter equation for such a system is: y[n] = bk x[n k] where bk = 1/L and L= length of filter. The following experiment will demonstrate the result of filtering of a noisy signal. TASK 1: 1. A signal i.e. x[n] =1.02n + cos(2n/8 +/4) is a signal corrupted by cos noise. 2. Plot this signal for 0 >= n >= 40 3. Apply the following filters and plot the results using both the inbuilt function filter() and loops a. 3 point averaging filter b. 5 point averaging filter c. 7 point averaging filter 4. Use subplot() to compare results. Which filter removes most noise? 5. What are the differences between the input signal and the results?

LAB 6

OBJECTIVE: To convert a time domain signal to frequency domain and vice versa. INTRODUCTION: Every signal can be written as a sum of sinusoids with different amplitudes and frequencies. Therefore, each time domain signal has an associated frequency domain representation. A time domain signal can be converted to frequency domain using the Fourier Transform. The Fourier Transform can also be used to remove noise from a signal. The MATLAB command to compute the Fourier Transform and its inverse are respectively fft and ifft. FFT is a very efficient method to calculate the Fourier transform. The following transformation happens:

Fig No. 1 TASK 1: 1. 2. 3. 4. Generate a random signal of 10 samples and plot it. Calculate its Fourier transform using the fast Fourier transform method. Calculate the Inverse FFT and plot its real part. Compare the two plots

TASK 2: 1. Plot the following signal for 4 seconds. y = 3*sin(4*2*pi*t) + 5*sin(2*2*pi*t) 2. Sample the given signal with Fs = 100 samples per second 3. Plot the sampled signal for time frame of 4 seconds with grid and labeled axis TASK 3: 1. Calculate and plot the frequency spectrum of the above signal using Fast Fourier Transform.
8

LAB 7 OBJECTIVE: Hands on with MATLAB GUI. Use of uigetfile and global functions INTRODUCTION: MATLAB offers an interactive Graphical User Interface suite. The following experiment takes input of a two dimensional signals (digital image) and performs basic operations on it using push buttons. TASK 1: Make a GUI with two push buttons and two axes which does the following actions: 1. 2. 3. 4. 5. 6. Explore the function uigetfile. Read an RGB image that is located on the desktop using a push button. Display this image on a new figure. Display this image on the axes of the GUI. Using another push button, convert this RGB image to gray scale. Show this gray scale image on new axes besides the previous one.

TASK 2: Add another push button and a text box to the GUI. 1. The push button should take an input angle from the textbox and rotate the gray scale image through that angle.

LAB 8 OBJECTIVE: Recording voice signals with microphones and displaying results. INTRODUCTION: MATLAB provides basic hardware connection for microphones and speakers. Speech/voice signals can be recorded and manipulated easily in MATLAB. Speech signals are continuous time signals which are sampled and quantized automatically by MATLAB; however, the sampling rate and quantization levels can be controlled. The function references for the following tasks are given below: TASK 1: 1. 2. 3. 4. 5. 6. 7. 8. 9. Make an object for audio recording using audiorecorder(). Record audio from this object using record(). Stop the recording and play the audio recorded. Is the replayed signal understandable? If not, why? Enhance the quality of this audio signal by varying sampling rate and quantization level. Record the sound again and play it. Save the recorded signal in a vector myaudio. Plot the signal. Zoom in the plot and observe the signal shape. What is the default format of this vector? Save this data in another vector in uint8 format.

TASK 2: 1. Record a voice signal for 10 seconds using microphone. Set sampling frequency 50000Hz and quantization level 32 bits/ sample. 2. Display the stem plot of samples of the first 5 seconds. 3. Multiply the amplitude of these samples by 2. 4. Display the stem plot of these samples. 5. Extract the value of 100,000th sample. To which class of integers does it belong?

10

LAB 9 OBJECTIVE: Hardware interface: Digital Camera Interface INTRODUCTION: Knowledge of signal processing is inadequate without the study of hardware interfacing and processing of real time signals. One of the most common signals is an image which can be captured using a digital camera. MATLAB has a strong toolbox for image processing with a huge library of inbuilt functions. The following tasks demonstrate the basics of reading and displaying live images and videos. TASK 1: 1. Attach an external web cam to the system. Use the imaqhwinfo() function to list all the adaptors available on the current system. 2. Use the deviceinfo() function to extract detailed information of the adaptor to be used. TASK 2: 1. Use the videoinput() function to create a connection object between MATLAB and the camera. 2. Test the connection using preview() 3. Take a picture from this camera using getsnapshot() TASK 3: 1. Convert the image taken from the camera to grayscale using rgb2gray(). 2. Convert the image taken from the camera to binary using im2bw(). TASK 4: 1. Clear and clean up space occupied by deleting the connection object.

11

LAB 10

OBJECTIVE: Hands on with MATLAB Simulink INTRODUCTION: Simulink stands for Software for modeling, simulating and analyzing dynamic systems. It is a tool for model-based design. Simulink is hence a strong tool for signal processing modeling and visualization. TASK 1: 1. Open a new Simulink canvas and view a standard sine wave using a scope. 2. Increase the sine wave amplitude by varying its properties. 3. Similarly generate and view the following from the Simulink source library a. Pulse Generator, b. Ramp, c. Repeating sequence d. Step TASK 2: 1. Generate a sine wave of amplitude 2. 2. Multiply the sine waves amplitude by 2 by using the gain component. Use the autoscale option to view complete wave on screen. 3. Is there any other way of doubling the amplitude of a signal? If so then implement it.

TASK 3: 1. Generate a random noise signal using signal generator component. 2. Add this noise to the sine wave from task 2.

TASK 4: 1. Use the derivative block to display the derivative of sine wave on the scope. 2. Display the input sine wave and its derivative on the same scope using MUX block. TASK 5: 1. Record a video and read and display it using multimedia blocks of IVP Blockset.

12

Vous aimerez peut-être aussi