0% found this document useful (0 votes)
56 views5 pages

Systems Analysis Using MATLAB

This document discusses convolution and how it can be performed using MATLAB. Convolution is a complicated operation that involves integrating, multiplying, adding, and time-shifting two signals together. MATLAB has conv and deconv commands that can perform 1D convolution on vectors. Examples are provided showing how to convolve vectors and find the central part of the convolution using conv with the 'same' option. A 2D convolution example is also given using conv2 to convolve matrices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views5 pages

Systems Analysis Using MATLAB

This document discusses convolution and how it can be performed using MATLAB. Convolution is a complicated operation that involves integrating, multiplying, adding, and time-shifting two signals together. MATLAB has conv and deconv commands that can perform 1D convolution on vectors. Examples are provided showing how to convolve vectors and find the central part of the convolution using conv with the 'same' option. A 2D convolution example is also given using conv2 to convolve matrices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Systems Analysis Using

MATLAB

Convolution
:

:. .

Systems Analysis Using MATLAB

Convolution
Convolution (folding together) is a complicated operation involving
integrating, multiplying, adding, and time-shifting two signals together.
The convolution a * b of two functions a and b is defined as the function:

This operation can be performed using this MATLAB command:

conv
deconv
conv2
-------------------------Example:
a(s) = s2 + 2s + 3
b(s) = 4s2 + 5s + 6

Convolution using MATLAB functions conv and deconv:

Create two vectors and convolve them using MATLAB:


u = [1 1 1];
v = [1 1 0 0 0 1 1];
w = conv(u,v)
w =
1

Create two vectors. Find the central part of the convolution of


u and v that is the same size as u, using MATLAB:
u = [-1 2 3 -2 0 1 2];
v = [2 4 -1 1];
w = conv(u,v,'same')
w =
15

-9

-1

EXAMPLE
Convolution of X=cos(n^2)*sin(2*pi*n/5)*u(t) and
h=((0.9)^n)*(u(t)-u(t-10)) using MATLAB:
n=0:99;
unit=ones(1,100);
unit_10=[ones(1,11) zeros(1,89)];
h=((0.9).^n).*unit_10;
x=cos(n.^2).*sin(2*pi*n/5).*unit;
y=conv(x,h);
subplot(2,2,1);
stem(n,x);
subplot(2,2,2);
stem(n,h);
subplot(2,2,3);
stem(n,y(1:100));

2D Covolution
C = conv2(A,B)

computes the two-dimensional convolution of matrices


A and B.
EXAMPLE using MATLAB:
s = [1 2 1; 0 0 0; -1 -2 -1];
A = zeros(10);
A(3:7,3:7) = ones(5);
H = conv2(A,s);
figure, mesh(H)
V = conv2(A,s');
figure, mesh(V)
figure
mesh(sqrt(H.^2 + V.^2))

You might also like