% zadanie 13
fp = 150;

%czasy
t_1 = 0 : 1/fp : (2 -(1/fp));
t_2 = 2 : 1/fp : (4-(1/fp));
t_3 = 4 : 1/fp : (8 -(1/fp));
t_4 = 8 : 1/fp : 10;

%sygna³y
s_1 = sin(2*t_1*2*pi +0);
s_2 = sawtooth(10*t_2, 0.5); % 45stopni = pi/4
s_3 = 1/3*randn(1,length(t_3));
s_4 = sin(2*t_4*2*pi + pi/2); %90 stopni = pi/2

t= [t_1, t_2, t_3, t_4];
s= [s_1, s_2, s_3, s_4];

figure(5);
plot(t,s);
grid on;

%korelacja
tau_max =400;
t_kor = -tau_max/fp : 1/fp : tau_max/fp

kor1= xcorr(s,s,tau_max);
figure(2);
subplot(211);
plot(t_kor, kor1);