linear convolution using gui

19
LINEAR CONVOLUTION USING GUI PROJECT BY: > Priyanka G > Pranita > Nikita Kumar > Pallavi Manjunath > Ramya Mallya

Upload: ramya-r-mallya

Post on 21-Feb-2015

154 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Linear Convolution Using GUI

LINEAR CONVOLUTIONUSING GUI

PROJECT BY:> Priyanka G > Pranita> Nikita Kumar> Pallavi Manjunath> Ramya Mallya

Page 2: Linear Convolution Using GUI

convolution

Convolution is an integral concatenation of two signals.

It has many applications in numerous areas of signal processing. The most popular application is the determination of the output signal of a linear time-invariant system by convolving the input signal with the impulse response of the system.

Page 3: Linear Convolution Using GUI

The linear convolution of two continuous time signals x(t) and h(t) is given by:

For discrete time signals x(n) and h(n), the integration is replaced by a summation as follows:

Convolution mathematical expression

dthxthtxty )()()()()(

k

knhkxnhnxny )()()()()(

Page 4: Linear Convolution Using GUI

Convolution Graphical implementation

Changing the variable from n to k.

FOLDING h(k) resulting in h(-k)

SHIFTING h(-k) by n, resulting in h(n-k)

Element-wise MULTIPLICATION of the sequences x(k) and h(n-k)

SUMMATION of the product sequence resulting in the convolution value for x(n)*h(n)

Page 5: Linear Convolution Using GUI

Input:x(n)=[1,1,1]

Impulse Response:h(n)=[1,1,1]

Output:y(n)=x(n)*h(n) =[1,2,3,2,1]

Page 6: Linear Convolution Using GUI

Graphical user interfacegui

GUI  is a program interface that takes advantage of the computer's graphics capabilities to make the program easier to use.

Well-designed graphical user interfaces can free the user from learning complex command languages.  

It uses windows, icons, buttons and menus which can be manipulated by a mouse and a keyboard.

GUI can be created in Matlab, using the GUIDE.

Page 7: Linear Convolution Using GUI

>> guide

This will open the ‘Quick Start’ window.

Select the fist option: ‘Blank GUI (Default)’.

imPLEMENTING LINEAR CONVOLUTION USING GUI

Page 8: Linear Convolution Using GUI

Then, an untitled figurewill pop-up. You havesome components on

theleft menu, which youcan drag onto yourinterface.Here we need 4 editboxes.

1. Input x(n)2. Starting point of x(n)3. Input h(n)4. Starting point of h(n)

The static text boxes areused for naming.

We need 3 axes plots forx(n),h(n) and output,

andone push button toperform convolutionoperation.

Page 9: Linear Convolution Using GUI

Drag and drop the components on the MATLAB GUI. The size of your interface window can be reduced or increased by dragging its lower-right corner, as it’s done in other drawing programs.

When you double click on your components, the ‘Property Inspector’ window will appear and you can make necessary adjustments. Background color can also be changed.

Page 10: Linear Convolution Using GUI

You’ll be taken to the Matlab code (in the editor window) that will drive your interface. Matlab has automatically created functions related to your components.

The ‘Callback’ functions are the instructions that will be executed when the user pushes the buttons or does something with the components that you have included in your Matlab GUI. Here ‘CONVOLVE’ is the push button included so v need to program the push button with convolution code.

Page 11: Linear Convolution Using GUI

function varargout = pushbutton1_Callback(h, eventdata, handles, varargin) x = str2num(get(handles.input_x,'String'));ox = str2double(get(handles.input_ox,'String')); h1 = str2num(get(handles.input_h,'String'));oh = str2double(get(handles.input_oh,'String')); x1=x;h2=h1; lx=length(x);lh=length(h1);ex=ox+lx-1;eh=oh+lh-1;st=ox; hf=fliplr(h1); n1=[ox:ex];y3=[];

matlab code

Page 12: Linear Convolution Using GUI

for k=0:1:(lx+lh-2) n2=[(st-lh+1):st]; n=min(min(n1),min(n2)):max(max(n1),max(n2));y1=zeros(1,length(n));y2=y1;y1(find((n>=min(n1))&(n<=max(n1))==1))=x1;y2(find((n>=min(n2))&(n<=max(n2))==1))=hf;a2=sum(y1.*y2); y3=[y3,a2];st=st+1; end y=y3;

matlab code

Page 13: Linear Convolution Using GUI

axes(handles.axes_x)nnx=[ox:ex];stem(nnx,x)xlabel('n'); ylabel('x(n)');title('INPUT SIGNAL'); axes(handles.axes_h)nnh=[oh:eh];stem(nnh,h1)xlabel('n'); ylabel('h(n)');title('SYSTEM RESPONSE'); axes(handles.axes_y)nny=[(ox+oh):(ox+oh+lx+lh-2)];stem(nny,y)xlabel('n'); ylabel('y(n)');title('OUTPUT SIGNAL');msgbox(num2str(y));

matlab code

Page 14: Linear Convolution Using GUI

After entering the program save it and go to ‘Debug’ option. Then select ‘Run’.

execution

Page 15: Linear Convolution Using GUI

Enter the values of x(n) and h(n) and their starting points.

Press ‘CONVOLVE’ push button.

execution

Page 16: Linear Convolution Using GUI

When push button is pressed we get the convolved output

y(n) = x(n) * h(n)

and the input plots, and a message box that displays the values of the samples of the output signal.

execution

Page 17: Linear Convolution Using GUI

Applications of convolution

•In electronics engineering, the convolution of one function (the input signal) with a second function (the impulse response) gives the output of a linear time-invariant system (LTI). At any given moment, the output is an accumulated effect of all the prior values of the input function, with the most recent values typically having the most influence (expressed as a multiplicative factor). The impulse response function provides that factor as a function of the elapsed time since each input value occurred.

•In probability theory, the probability distribution of the sum of two independent random variables is the convolution of their individual distributions.

•In optics, many kinds of "blur" are described by convolutions. A shadow (e.g., the shadow on the table when you hold your hand between the table and a light source) is the convolution of the shape of the light source that is casting the shadow and the object whose shadow is being cast. An out-of-focus photograph is the convolution of the sharp image with the shape of the iris diaphragm.

Page 18: Linear Convolution Using GUI

Applications of convolution

•In linear acoustics, an echo is the convolution of the original sound with a function representing the various objects that are reflecting it.

•In artificial reverberation (digital signal processing, pro audio), convolution is used to map the impulse response of a real room on a digital audio signal (see previous and next point for additional information).

•In radiotherapy treatment planning systems, most part of all modern codes of calculation applies a convolution-superposition algorithm.In physics, wherever there is a linear system with a "superposition principle", a convolution operation makes an appearance.

Page 19: Linear Convolution Using GUI

We would like to thank our teacherand guide Mr. C.G. Raghavendra forgiving us the opportunity to work on

this project, and also for all his supportand his valuable inputs.

acknowledgements