Skip to content

Commit

Permalink
periodogram done
Browse files Browse the repository at this point in the history
  • Loading branch information
arnauochoa committed Nov 25, 2020
1 parent f7381ee commit 7436b13
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 29 deletions.
34 changes: 5 additions & 29 deletions main.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,28 @@

filepath = 'test_real_long.dat';

% signal = DataReader(filepath, Inf);

load('subsignal.mat');
Nsamp = 500*4096;
signal = DataReader(filepath, Nsamp);

N = 2^20;
fIF = 4.348e6; %Hz
fs = 23.104e6; %Hz

s = signal5000(1:4096);
s = signal(1:Nsamp);

omega = linspace(-2*pi, 2*pi, 2*N);

figure
plot(s, 'o-');
plot(s(1:200), 'o-');

figure;
histogram(s);
title('Quantized signal in time domain');
xlabel('k');

S = fft(s);

w = linspace(-2*pi,2*pi,length(s));
figure
plot(w, fftshift(abs(S)));
title('Quantized signal in frequency domain');
xlabel('w');

Rs = xcorr(s, 'biased');
Ss = fft(Rs, 2*N);

% figure;
% plot(fftshift(abs(Ss)));
% title('Spectral density from autocorrelation');
% xlabel('w');
%
% [Ss, f] = periodogram(s, rectwin(length(s)), [], fs);
% figure
% plot(f/1e6, 10*log10(Ss));
% % plot([-flip(f); f], [flip(Ss); Ss]);
% title('Periodogram');
% xlabel('f (MHz)'); ylabel('PSD (dB/Hz)')

[Swelch, fwelch] = pwelch(s, 30, 15, [], fs);
[Swelch, fwelch] = pwelch(s, 256, 0, 256, fs);
figure
% plot([-flip(fwelch); fwelch]./1e6, [flip(Swelch); Swelch]);
plot(fwelch./1e6, 10*log10(Swelch)); hold on;
xline(fIF/1e6);
xlabel('f (MHz)'); ylabel('PSD (dB/Hz)');
Expand Down
Binary file removed subsignal.mat
Binary file not shown.

0 comments on commit 7436b13

Please sign in to comment.