필터 지우기
필터 지우기

How do I do the fourier transform of a data array?

조회 수: 34 (최근 30일)
Goncalo Costa
Goncalo Costa 2022년 6월 18일
댓글: Star Strider 2022년 6월 20일
I have been trying to do the fourier transform of a reference signal and of a row of signals, but the results I am getting are not the way they should be. What am I doing wrong?
I have got a two data arrays, the first is a reference signal and the second are 240 individual main signals (obtained over a period of 60 seconds). These signal are THz signals and their Fourier Transform is expected to take a certain shape, as shown in the the figure below (left shows the signal and right shows the fourier of the signal):
Fig.1 - Stereotypical FFT of a THz signal.
Each signal (the reference and the 240 main data signals) is composed of 1496 points.
The reference is : 1 x 1496;
The main signal is : 1496 x 240 (I was too lazy to make a transpose of this, but it can be easily done).
To get the fourier transform of said signal I have written the following:
ref_ft = fft(ref_clean); %ref_clean is the reference signal 1 x 1496;
for p=1:240
data_ft(:,p)=fft(data_clean(:,p)); %data clean are the main 240 signals, 1496 x 240 ;
end
plot(freq, ref_clean); %plotting them against frequency
plot(freq, data_clean)
Fig. 2 - My FFT of the reference signal
This, in no shape of form looks like examples shown in Fig. 1. What could I be possibly doing wrong? Is it potentially the shape of my data? I don't think it is because my reference is a simple shape and I haven't had to put it through a for loop.
Any help would be deeply appreciated.
I have attached the data files in case anyone finds something weird about them.

채택된 답변

Star Strider
Star Strider 2022년 6월 18일
Try this —
% LD1 = load('ref_clean.mat');
% ref_clean = LD1.ref_clean;
LD2 = load('data_clean.mat');
data_clean = LD2.data_clean;
figure
waterfall(data_clean)
grid on
xlabel('rows')
ylabel('cols')
title('Signal Matrix')
Fs = 1; % Default Sampling Frequency (Actual Value Unstated)
Fn = Fs/2; % Nyquist Frequency
L = size(data_clean,1); % Signal Length
NFFT = 2^nextpow2(L); % For Efficiency
FTd_c = fft(data_clean,NFFT)/L;
Fv = linspace(0, 1, NFFT/2+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
for k = 1:fix(size(FTd_c,2)/20)
idx = 12*(k-1)+1;
subplot(6,2,k)
plot(Fv, abs(FTd_c(Iv,idx))*2)
grid
xlabel('Frequency (Units)')
ylabel('Amplitude')
title(sprintf('Row %3d',idx))
end
Fh = gcf;
pos = Fh.Position;
Fh.Position = pos + [-100 -500 200 500]; % Expand To Show Detail
I have no idea what ‘ref_clean’ is, so I didn’t use it.
All the signals appear to be essentially the same, so their Fourier transforms are also essentially the same.
Supply the appropriate value of ‘Fs’ to get the correct frequency vector.
.
  댓글 수: 4
Goncalo Costa
Goncalo Costa 2022년 6월 20일
Thank you very much for your help. I think I understand it now (at least most of it).
Each 240 measurements were taken over a period of 60 secs, so I changed Fs to be 4. I think this was the correct thing to do.....
I have also made alterations in the plot to plot every single Fourier transform.
For anyone else having doubts regarding the Frequency vector and the Index Vector, as well as the NFFT there are some links below that might help:
Star Strider
Star Strider 2022년 6월 20일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by