[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tftb-help] question about the energy function margtfr

From: ting xu
Subject: [Tftb-help] question about the energy function margtfr
Date: Tue, 18 Dec 2012 19:51:59 +0800


I have two questions about the energy calculation of time series. I searched archives but did not find answer. 
So here is my question, anyone meet the similar problem, I am grateful for your comments.

To test the energy calculation, I tried the following scripts to test if the total energy from fft is equal to which from wavelet

t=1:600; N=length(t);

ts=cos(2*pi*0.3*t')+3*cos(2*pi*0.1*t');  % for example here

f = (1:N/2)/N;

a = abs(fft(ts))/(N/2); a = a(1:N/2);

[wtfr,~,f_wt,~]=tfrscalo(ts,1:N,sqrt(N),0.001,0.5); % wavelet transform

% total Energy

fE = integ(a'.^2,f)*N

[~,~,wE] = margtfr(wtfr,t,f_wt)

Yes, fE here is equal to wE. But when I concentrated on low frequency band, e.g. f<0.2,  the function margtfr would give me wrong answer. 
% low frequency Energy from fft

idx_fft = find( f < 0.2, 1, 'last');

a_low = a(1:idx_fft); f_low = f(1:idx_fft);

fE_low = integ(a_low'.^2,f_low)*N

low frequency Energy from wavelet

idx_wt = find( f_wt < 0.2, 1, 'last');

wtfr_low = wtfr(1:idx_wt,:); f_wt_low = f_wt(1:idx_wt);

[~,~,wE_low] = margtfr(wtfr_low, t, f_wt_low) 

% In margtfr function, wE_low is calculated by the following equation

% wE_low = integ2d(wtfr_low, t, f_wt_low)/size(wtfr_low,1)

Specifically, Low frequency energy from wavelet (wE_low) does not equal to energy from fft (fE_low) . I check the function margtfr, E = real( integ2d ( tfr, t, f ) / M), M is the total number of frequency points of tfr matrix. then I changed the scripts like this

[M, N] = size(wtfr);

wE_low = integ2d(wtfr_low, t, f_wt_low)/M

The result looks right. But I am still confused, why should we use M here (total number of row in wtfr matrix), instead of the number of row in wtfr_low matrix ?

Much appreciate!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]