FFT analysis of multiple signals with the same response length

I have a dataset of the responses of a dynamic system in a time- domain. The signal is 1 second long and sampling frequency is 2000 Hz. I have 100 of different system configurations, meaning that my dataset has the shape of 2000x101, where the column 1 represents time and the rest columns are reponses of the system. How to perform FFT analysis for each signal and save obtained signals in frequency- domain to the new dataset? By this moment I can perform FFT only for 1 signal, the code is below. Obviously, for loop is need for this operation, but I don't have much experience to implement it for this problem.
%load data
Data = Data4FFT(:,2);
Time1= Data4FFT(:,1);
L = numel(Data);
Fs = 2000;
Fn = Fs/2;
Ts = 1/Fs;
t = linspace(0, L, L)*Ts;
FTS = fft(Data)/L;
FvHz = linspace(0, 1, fix(L/2)+1)*Fn;
Iv = 1:numel(Fvrs);
figure(2)
plot(FvHz, abs(FTS(Iv))*2)
grid
xlabel('Frequency (Hz)')
ylabel('Amplitude')
title('Response in Frequency Domain')

 Accepted Answer

The fft function operates column-wise (unless the argument is a vector or you tell it otherwise), so this is all that is necessary:
Data4FFT = [((0:1999).'*5E-4), rand(2000,100)]; % Create Matrix
L = size(Data4FFT,1); % Signal Length
t = Data4FFT(:,1); % ‘... first column is time ...’
Data = Data4FFT(:,2:end);
Fs = 2000;
Fn = Fs/2;
Ts = 1/Fs;
FTS = fft(Data - mean(Data))/L; % Subtract Mean To Eliminate D-C Offset
FvHz = linspace(0, 1, fix(L/2)+1)*Fn;
Iv = 1:numel(FvHz);
figure(2)
plot(FvHz, abs(FTS(Iv))*2)
grid
xlabel('Frequency (Hz)')
ylabel('Amplitude')
title('Response in Frequency Domain')
You might want to plot the fft results individually, display the mean of all of them, or use the ribbon function to see them all at once.

4 Comments

Thanks for the quick response, maybe my code was misleading, I made the plot just to check how the FFT is performed, but as an output I would like to get the matrix which would include individual responses in Frequency domain for each column of initial matrix, basically I want to do FFTs for each column of my data separately and get 100 columns containing the amplitudes and one column with frequencies. Hope, it's more clear now.
My code does exactly that.
The two-sided fft results are in the ‘FTS’ matrix.
To create a matrix of one-sided fft results and associated frequency vector in the first column:
FTSmtx = [FvHz.' FTS(Iv,:)];
so that ‘FTSmtx’ is now a (1001 x 101) matrix, as requested.
Thanks a lot, now it gives the needed output!

Sign in to comment.

More Answers (0)

Products

Release

R2018a

Community Treasure Hunt

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

Start Hunting!