how to create the frequency vector on FFT

10 ビュー (過去 30 日間)
Eva
Eva 2020 年 4 月 2 日
回答済み: Georges Theodosiou 2020 年 10 月 13 日
FileName='Book2.xlsx';
a=xlsread(FileName);
time=a(:,1);
TC1=a(:,2);
TC13=a(:,3);
TC21=a(:,4);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subplot(2,2,1);
TC1_hat=fft(TC1);
L=length(TC1);
dt = .01;
fs=1/dt;
f=fs*(0:(L/2))/L;
plot(f,TC1_hat(1:numel(f))*2)
title(' FFT CONDENSER')
xlabel('FREQUANCY')
ylabel('AMPLITUDE')
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
subplot(2,2,2);
TC13_hat=fft(TC13);
plot(f,TC13_hat(1:numel(f))*2)
title(' FFT ADIABATIC')
xlabel('FREQUANCY')
ylabel('AMPLITUDE')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%
subplot(3,2,[3,4]);
TC21_hat=fft(TC21);
plot(f,TC21_hat(1:numel(f))*2)
title(' FFT Evaporator')
xlabel('FREQUANCY')
ylabel('AMPLITUDE')
%%%%%%%%%%%%%%%%%%%%%%%%%%
Hi ,
I was trying to make FFT for 3 signals and plot the relation between the Amplitude and the frequency , but actullay I'm not sure about the frequency vector that I write it in the code , is it right ? also how can I determine the range for f ? also always when I run the code , show this msg ( Warning: Imaginary parts of complex X and/or Y arguments ignored )
ps : the number of data in each column is 33034 and the time from 0 - 330.33 ( step .01 )
  3 件のコメント
Eva
Eva 2020 年 4 月 2 日
Thank you for your response I add in my code the abs(TC13_hat) and the msg stop to show and I read all the examples in this link many time , I just now have one problem which is I'm not sure about the frequencey range and how to choose it ?
dpb
dpb 2020 年 4 月 2 日
Your code above doesn't reflect any such change so can't judge...in particular the issue regarding which points are part of the frequency spectrum to return and the scaling as shown in the example and discussed at another recent Q? I responded to <Answers/514367-fft-using-excel-data> talks about and show the particular point in the example that isn't included in your code above. As noted in this Q?, if the DC component is small (the signal is zero-mean), then it won't make much difference, but it still isn't precisely correct.
Your code above
time=a(:,1);
...
dt = .01;
...
reads a time vector as the first column but then sets a sample rate externally to 0.01. There's no way to know without the data if those two are commensurate with each other; ergo there's no way to know if you have the right frequency vector or not.
What is the difference between a(2,1)-a(1,1)? Does that match dt? Is your plotted maximum frequency the expected value?
BTW, it would be simpler to code if you would use the original array a and subscript it for the various columns instead of creating independent named variables for each that require duplicating the same code over and over...

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

回答 (2 件)

Daniel Frisch
Daniel Frisch 2020 年 8 月 31 日
You can use my little tool easyFFT. It calculates & returns the frequency vector along with the FFT.

Georges Theodosiou
Georges Theodosiou 2020 年 10 月 13 日
Lady Eva,
Please let me help you a bit. Function findpeaks helps in your case.
With regards and friendship,
Georges Theodosiou

カテゴリ

Help Center および File ExchangeSpectral Estimation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by