Time stamp for discrete Fourier transform

Hi all,
I am trying to create a time stamp for my weather data. I took my readings every three hours for simplicity sake lets say I just want four days and a half of August how can I do this? Attach is my attempt with my previous try.
Thanks in advance
a=[ 27 26 24 29 35 38 37 35 31 28 27 31 36 39 39 35 35 32 28 26 30 37 40 39 36 33 ]
a1=mean(a)%mean of matrix A
a2=a-a1;%subtraction of the mean at each observation
t1=datetime(2015,8,2);%time stamp attemp 1
t2=datetime(2015,8,6);
t1:hours(3):t2
y=fft(a2);

 Accepted Answer

Try this:
a=[ 27 26 24 29 35 38 37 35 31 28 27 31 36 39 39 35 35 32 28 26 30 37 40 39 36 33 ]
a1=mean(a)%mean of matrix A
a2=a-a1;%subtraction of the mean at each observation
t1=datetime(2015,8,2);%time stamp attemp 1
t2=datetime(2015,8,6);
tv = t1:hours(3):t2;
L = numel(a); % Nr Samples
Ts = 3/24; % Sampling Interval (Units: Days)
Fs = 1/Ts; % Sampling Frequency (Units: Cycles/Day)
Fn = Fs/2; % Nyquist Frequency (Units: Cycles/Day)
y=fft(a2)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
plot(Fv, abs(y(Iv))*2)
grid
xlabel('Frequency (Cycles/Day)')
ylabel('Amplitude')
Experiment to get different results.

2 Comments

Thanks! I was kinda lost with this but now I understand!
As always, my pleasure!

Sign in to comment.

More Answers (0)

Categories

Find more on Fourier Analysis and Filtering 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!