0% found this document useful (0 votes)
30 views2 pages

% Clear All The Variables Used Before %clear The Screen: For For End End For For End For End For End End For For End End

This document generates a random input signal, impulse signal, convolutes the two signals using multiplication and shifting, and adds the results to produce the convoluted signal. It plots the input, impulse, and convoluted signals. The input is 10000 random values, the impulse is a vector of length 2, and convolution produces a signal of length 10000 + 2 - 1 = 10001.
Copyright
© Attribution Non-Commercial (BY-NC)
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)
30 views2 pages

% Clear All The Variables Used Before %clear The Screen: For For End End For For End For End For End End For For End End

This document generates a random input signal, impulse signal, convolutes the two signals using multiplication and shifting, and adds the results to produce the convoluted signal. It plots the input, impulse, and convoluted signals. The input is 10000 random values, the impulse is a vector of length 2, and convolution produces a signal of length 10000 + 2 - 1 = 10001.
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 2

clear all;

% clear all the variables used


before
clc;
%clear the screen
x=rand(1,10000);
h=[.5 .2];
x1=length(x);
x2=length(h);
a=0:1:x1-1;
%range of a is given
b=0:1:x2-1;
%Multiplication
for i=1:x1
for j=1:x2
c(j,i)=x(1,i)*h(1,j);
end
end
%Shifting
for i=1:x2
for j=1:i-1
d(i,j)=0;
end
for k=i:i+x1-1
d(i,k)=c(i,k-i+1);
end
for m=i+x1:x1+x2-1
d(i,m)=0;
end
end
%Addition
for i=1:x1+x2-1
con(i)=0;
for j=1:x2
con(i)=con(i)+d(j,i);
end
end
subplot(3,1,1)

stem(a,x)
title('Input signal');
subplot(3,1,2)
stem(b,h)
title('Impulse signal');
subplot(3,1,3)
stem(con)
disp(con)
title('Convoluted signal')

Input signal
1
0.5
0

1000

2000

3000

4000

5000

6000

7000

8000

0.7

0.8

9000 10000

Impulse signal
0.5

0.1

0.2

0.3

0.4

0.5

0.6

0.9

Convoluted signal
1
0.5
0

2000

4000

6000

8000

10000

12000

You might also like