frequency axis to time axis in power spectral density

3 views (last 30 days)
Hi all
I have 120 data points for 120 days. and plotted power spectrum as shown in code.. now my doubt is that how to convert frequency axis to time period axis. i defined frequency as
T = number of days (120); f = (0:N/2-1)/T;
then I have plotted power spectrum with frequency axis
then I want to plot power spectrum with time axis..
Now my doubt is period = 1./f; or period = f.*T; ......???? which one is correct.. I was trying to solve this from many days.. some of my friends are telling first is right. some are telling second is right. I am completely lost. somebody help me out..
Thanks in advance
u = xlsread('sample.xlsx');
N= length(u); % number of data points
T = N;
f = (0:N/2-1)/T; per = f.*T; period = 1./f;
p_sur_cur= abs(fft(u)/2+1)/(N); % absolute value of the FFT
pow_sur = p_sur_cur(1:(N/2)).^2; % take the power of positive freq half
plot(f,pow_sur,'color','r')
figure
plot(period,pow_sur)

Answers (0)

Categories

Find more on Oceanography and Hydrology in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!