You are on page 1of 1

b = 10000; %Sampling Rate

h = zeros(1,8 * b);
x = zeros(1,8 * b);
t = linspace(-3,5,8 * b);
h(2 * b:3 * b) = (1 * t(2 * b:3 * b)) + 1; %Increasing Interval of the
Triangular Wave
h(3 * b:4 * b) = (-1 * t(3 * b:4 * b)) + 1; %Decreasing Interval of the
Triangular Wave
x(4 * b:5 * b) = 1;
subplot(3,1,1);plot(t,x);

%Rectangular Wave
%Plotting the Signal

title('Rectangular signal x(t)');


xlabel('Time (in seconds)');
ylabel('Signal amplitude');
subplot(3,1,2);plot(t,h);

%Plotting Impulse Response

title('Triangular signal h(t)');


xlabel('Time (in seconds)');
ylabel('Signal amplitude');
y1 = (1 / b) * conv(x,h);
y = y1(3 * b:11 * b - 1);
subplot(3,1,3);plot(t,y);
title('Convolution result y(t)');

%Plotting Convolved Output

xlabel('Time (in seconds)');


ylabel('Convolved Signal amplitude');

You might also like