Você está na página 1de 4

Experiment 12

Object: Write a MATLAB program to develop a signal y(n) generated by a convolution of two sequences
x(n) and h(n).Also Verify the result using inbuilt functions.

Software Used: MATLAB Theory: In mathematics and, in particular, functional analysis, convolution is a mathematical operation on

two functions f and g, producing a third function that is typically viewed as a modified version of one of the original functions, giving the area overlap between the two functions as a function of the amount that one of the original functions is translated. Convolution is similar to cross-correlation. It has include probability, statistics, computer vision, image and signal processing , and differential equations. The convolution of f and g is written f*g, using an asterisk or star. It is defined as the integral of the product of the two functions after one is reversed and shifted. As such, it is a particular kind of integral transform: applications that electrical engineering,

While the symbol t is used above, it need not represent the time domain. But in that context, the convolution formula can be described as a weighted average of the function f() at the moment t where the weighting is given by g() simply shifted by amount t. As t changes, the weighting function emphasizes different parts of the input function. The discrete convolution of f and g is given by:

32

Convolution By Matrix Method

Source Code:clear all; close all; clc; x=input('Enter the input sequence x[n]: '); h=input('Enter the input sequence h[n]: '); b=length(x); c=length(h); u=b+c-1; for i=1:b for j=1:c f(j,i) = x(i) .* h(j); end; end;

for a=1:u y(a)=0; for i=1:b


33

for j=1:c if(i+j) == a+1; y(a)=y(a) + f(j,i); end; end; end; end; subplot(2,2,1); stem(x); xlabel('<---- n --->'); ylabel('<---- x[n] ---->'); title('Input sequence x[n]'); subplot(2,2,2); stem(h); xlabel('<---- n -->'); ylabel('<---- h[n] -->'); title('Input sequence h[n]'); subplot(2,2,3); stem(y); xlabel('<--- n --->'); ylabel('<--- y[n] --->'); title('Output sequence y[n] using Matrix Multiplication'); subplot(2,2,4); stem(conv(x,h)); xlabel('<--- n --->'); ylabel('<--- y[n] --->'); title('Output sequence y[n] using inbuilt fuction');

Results:
Output on Command Window:Enter the input sequence x[n]: [2 5 4 6 7 4] Enter the input sequence h[n]: [2 3 4 5 4 3] >>

34

Conclusion: The signal y[n] was generated by a convolution of two sequences x[n] and h[n] using Matrix
Multiplication and also verified using MATLAB inbuilt functions.

35

Você também pode gostar