FFT analysis of multiple signals with the same response length

10 views (last 30 days)
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

Star Strider
Star Strider on 23 Jan 2020
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

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!