Time stamp for discrete Fourier transform
4 views (last 30 days)
Show older comments
desert_scientist90
on 19 Dec 2019
Commented: Star Strider
on 19 Dec 2019
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);
0 Comments
Accepted Answer
Star Strider
on 19 Dec 2019
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
More Answers (0)
See Also
Categories
Find more on Matrices and Arrays 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!