%HELSINKI UNIVERSITY OF TEHNOLOGY
%Communications Laboratory
%Seppo Saastamoinen 5.2.2005

%S-72.060 SIGNALS AND SYSTEMS
%Laboratory work 3: Convolution
%Makro: convo1en.m

clear all; close all; %Clear all variables and figures.

Fs = 1024; %Sample frequency 1024 Hz;
t = (-1:1/Fs:8); %Time domain (vector);

xt = 2*rectpuls(t-2,4); %Square puls, amplitude 2 V, time delay 2 s, duration 4 s.;
ht = 3*tripuls(t-1,2); ; %Triangle puls, amplitude 3, time delay 1 s, duration 2 s.;
yt = conv(xt,ht)/Fs; %Convolution between xt and yt;
t2 = (-2:1/Fs:16); %Time vector for yt because of the convolution duration.;

subplot (3,1,1);
plot (t,xt); 
axis ([-1 8 -0.5 2.5]);
xlabel ('Time/s');
ylabel ('xt, input voltage/V');
grid on;
zoom on;

title({'Square puls and triangle puls, convolution','Give here your names and student numbers and give date'});

subplot(3,1,2);
plot(t,ht);
xlabel ('Time/s');
ylabel ('ht, impulse response');
axis([-1 8 -0.5 3.5]);
grid on;

subplot(3,1,3);
plot(t2,yt);
axis([-1 8 -0.5 6.5]);
xlabel ('Time/s');
ylabel ('yt, output voltage/V');
grid on;

shg;
