Skip to content

Instantly share code, notes, and snippets.

@piotrek-k
Created January 29, 2019 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piotrek-k/aae4f54fba77717a89a57abeaab18909 to your computer and use it in GitHub Desktop.
Save piotrek-k/aae4f54fba77717a89a57abeaab18909 to your computer and use it in GitHub Desktop.
% Grupa B
% 1)
N = 4000; % ilość próbek
fp = 2000; % częstotl. próbkowania Hz
t = (0) : (1/fp) : (N/fp);
x = chirp(t, 100, N/fp, 900); % syngał sinusoidalny
y = randn(1, N+1); % szum o rozkladzie normalnym
suma_syg = x + y;
subplot(4, 1, 1);
plot(t, suma_syg);
title('Suma sygnalu sinusoidalnego i szumu o rozkladzie normalnym');
xlabel('czas');
ylabel('wartosc probki');
% 2)
fft_length = 2^12; % dlugosc tranformaty
widmo = fft(suma_syg, fft_length);
mod_widma = abs(widmo); % widmo aplitudowe - część rzeczyista funkcji zespolonej
os_czestotl = 0: 1 : fft_length-1;
subplot(4, 1, 2);
plot(os_czestotl, mod_widma);
title('Moduł widma sygnału');
xlabel('os częstotliwosci');
ylabel('częstosc występowania');
% 3)
opoznienie = 2000*0.2; % ilosc probek na sec * 0.2
autokorelacja = xcorr(suma_syg, suma_syg, opoznienie);
os_t = (-opoznienie/2) : (1/fp*1000) : (opoznienie/2);
subplot(4, 1, 3);
plot(os_t, autokorelacja);
title('Autokorelacja sygnalu');
xlabel('przesuniecie');
ylabel('wartosc korelacji');
% 4)
szum = randn(1, N+1); % szum o rozkladnie normalnym
% 5)
korelacja_wzajemna = xcorr(suma_syg, szum, opoznienie);
subplot(4, 1, 4);
plot(os_t, korelacja_wzajemna);
title('Wzajemna korelacja szumu i sygnalu suma_syg');
xlabel('przesuniecie');
ylabel('wartosc korelacji');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment