%Demo-script for DSP-Lab session 3: DFT
%This scripts shows some effects of the FFT on the
%Agilent 54622D Scope

N = 2048;   % Number of points
f = 0.02;   % normalized frequency; 1 ^= f_s
%f = 16/512;

% sine wave; rectangular window 
n = 0:(N-1);
x = sin(2*pi*f*n) * (2/N);

figure(1), clf, plot(n,x,'.-')

X = fft(x);

figure(2), clf, plot(n,20*log10(abs(X)),'.-'), axis([0,N,-70,10])

% sine wave; 2000 samples taken -> zero padded to 2048 for FFT
% -> produces same image as Agilent-Scope

x_hp = x .* [boxcar(2000)' zeros(1,48)];

figure(1), hold on, plot(n,x_hp,'mo--')

X_hp = fft(x_hp);

figure(2), hold on, plot(n,20*log10(abs(X_hp)),'mo--')
