how to do Fourier transform with current data

4 ビュー (過去 30 日間)
dang khoa tran
dang khoa tran 2019 年 12 月 29 日
コメント済み: Star Strider 2019 年 12 月 29 日
Hello,
I have a set of data as shown in the attactment, in which the "t_spectrum" shows the time and "y_spectrum" shows the electric field amplitude. And from this I want to do Fourier transform from these data. I have tried fft function but it seems that the spectrum is not reasonable.
So could anyone please recommend some approaches to that?
Thank you very much

採用された回答

Star Strider
Star Strider 2019 年 12 月 29 日
Try this:
E = dlmread('y_spectrum.txt',' ',1,0);
t = dlmread('t_spectrum.txt',' ',1,0);
Ts = mean(diff(t));
Fs = 1/Ts;
Tstd = std(diff(t));
Fs = 12E+15; % Sampling Frequency
[Er,tr] = resample(E,t,Fs); % Resample To Regularly-Spaced Intervals
figure
plot(t,E,'.b')
hold on
plot(tr,Er,'-r')
hold off
grid
legend('Original E', 'Resampled E')
Fn = Fs/2; % Nyquist Frequency
L = numel(tr); % Vector Lengths
Erm = Er - mean(Er);
FT_Erm = fft(Er)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn;
Iv = 1:numel(Fv);
[pks,locs] = findpeaks(abs(FT_Erm(Iv))*2, 'MinPeakHeight',3E+10);
figure
plot(Fv, abs(FT_Erm(Iv))*2)
hold on
plot(Fv(locs), pks, '.r')
hold off
grid
text(1.5E+15, 7.5E+10, sprintf('Peak %10.3E Frequency %10.3E\n', [pks Fv(locs).'].'))
producing:
1how to do Fourier transform with current data - 2019 12 28.png
I am not certain what does not appear to be ‘reasonable’ about it. It looks good to me.

その他の回答 (1 件)

dang khoa tran
dang khoa tran 2019 年 12 月 29 日
Thank you very much.
Your answer is very complete. I mention "not reasonable" since the spectrum is very ugly. And the reason is that the resampling is not included in my code.
Anyway, thank you again.
  1 件のコメント
Star Strider
Star Strider 2019 年 12 月 29 日
As always, my pleasure!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDiscrete Fourier and Cosine Transforms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by