2019/11/06

Matlab: Parseval's theorem

Parseval's theorem states that for N discrete points of signal,

Total Energy ∑ |x[n]|2 = 1/N × ∑ |X[k]|2

where X[k] is the kth point of the discrete Fourier transform of x[n].

Let's check this with Matlab:


load mtlb; %Load "Matlab" sound example

N = 128;
y = mtlb(1:N); %Read the 1st 128 points only

%Check Parseval's theorem

%y^2
y_2 = y.^2;

%Energy
energy = sum(y_2)

%Frequency domain
y_fft = fft(y); %Complex double

%|y_fft|^2

y_fft_2 = abs(y_fft).^2;

y_fft_2_check = y_fft.*conj(y_fft); %Should be identical to y_fft_2

energy_fft = sum(y_fft_2)/N

energy_fft_check = sum(y_fft_2_check)/N

Result:

Reference:

energy =

    2.5595


energy_fft =

    2.5595


energy_fft_check =

    2.5595

>> 

Parseval's theorem (Wikipedia)

沒有留言:

張貼留言