## Wednesday, October 8, 2014

### How to Make Convolution Function Using Matlab Version R2009a

Robotronicdiagram. - In the first Matlab lesson programming, we will give you listing program for convolution function or we will guide you to make convolution function that based on Matlab software version R2009a.

 Figure 1. Convolution using Matlab Toolbox and Own Function

In here we will give you firstly description about what is convolution from Matlab toolbox and then we will give you listing program that we programmed with our self logical and give the same result with we using the Matlab toolbox.

Let we begin our lesson about convolution function from Matlab function toolbox.

# convolution

Convolution and polynomial multiplication

## Syntax

w = conv(u,v)

C = conv(...,'shape')

## Description

w = conv(u,v) convolves vectors u and v. Algebraically, convolution is the same operation as multiplying the polynomials whose coefficients are the elements of u and v.
C = conv(...,'shape') returns a subsection of the two-dimensional convolution, as specified by the shape parameter:
 full Returns the full two-dimensional convolution (default). same Returns the central part of the convolution of the same size as A. valid Returns only those parts of the convolution that are computed without the zero-padded edges. Using this option, C has size [ma-mb+1,na-nb+1] when length(c) is max(length(a)-max(0,length(b)-1),0)

## Definition

Let m = length(u) and n = length(v) . Then w is the vector of length m+n-1 whose kth element is

The sum is over all the values of j which lead to legal subscripts for u(j) and v(k+1-j), specifically j = max(1,k+1-n): min(k,m). When m = n, this gives
```
w(1) = u(1)*v(1)

w(2) = u(1)*v(2)+u(2)*v(1)

w(3) = u(1)*v(3)+u(2)*v(2)+u(3)*v(1)
...

w(n) = u(1)*v(n)+u(2)*v(n-1)+ ... +u(n)*v(1)
...

w(2*n-1) = u(n)*v(n)
```

## Algorithm

The convolution theorem says, roughly, that convolving two sequences is the same as multiplying their Fourier transforms. In order to make this precise, it is necessary to pad the two vectors with zeros and ignore roundoff error. Thus, if
`X = fft([x zeros(1,length(y)-1)])`
and
`Y = fft([y zeros(1,length(x)-1)])`

then conv(x,y) = ifft(X.*Y)

According the concept of convolution above you can easily use function convolution using syntax "conv" for example:

And now you can try to use our convolution function that we arrange with the function name "konvolusi" like example below and see the result.

We know that our function and Matlab toolbox function give result same. And to test the result you can use the others input x and h.

And here are the listing program that we make for convolution function as follow:

Thank you for your coming here in www.robotronicdiagram.com, we hope the article above will help you to know more about your information in electronic circuit design and other in this time. Please comment here when you want to share and other. Thank you.