Time stamp for discrete Fourier transform

조회 수: 1 (최근 30일)
desert_scientist90
desert_scientist90 2019년 12월 19일
댓글: Star Strider 2019년 12월 19일
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);

채택된 답변

Star Strider
Star Strider 2019년 12월 19일
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
desert_scientist90
desert_scientist90 2019년 12월 19일
Thanks! I was kinda lost with this but now I understand!
Star Strider
Star Strider 2019년 12월 19일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by