Integration of fft signal

10 views (last 30 days)
Moza Mohamed
Moza Mohamed on 15 Feb 2022
Edited: Paul on 3 Apr 2025
I have the following code
m=importdata("Raw data (1).csv")
t=m(:,1)
v=m(:,2)
L = length(t);
Ts = t(2)-t(1); % Sampling Interval (sec)
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2;
Good = v- mean(v); % Remove D-C (Constant) Offset
Y = fft(v)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:length(Fv); % Index Vector For Plot
figure(1)
plot(Fv, 2*abs(Y(Iv)))
grid
xlabel('Frequency')
ylabel('Magnitude')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I would like to integrate the signal. How is this possible ?

Answers (2)

Soumya
Soumya on 3 Apr 2025
Hi Moza,
There are many ways in MATLAB to integrate discrete data, like the FFT signal in your case. One common approach is to use the trapezoidal rule, which can be implemented in MATLAB using the cumtrapz function. The cumtrapz function computes the cumulative integral of a vector using the trapezoidal rule, returning a vector of integrated values at each point:
Q = cumtrapz(X,Y);
You can also use the ‘trapz’ function to compute the total integral, which provides a single scalar value that represents the integral over the entire data range:
Q = trapz(X,Y)
Please refer to the following documentation to get more information on:
I hope this helps!

Walter Roberson
Walter Roberson on 3 Apr 2025
fft() is inherently a discrete process. Integration is inherently a continuous process.
"numerc integration" assumes that the underlying data is a discrete representation of a continous function. However, with fft() being inherently discrete, it is not true that fft() is a discrete representation to a continuous function.
So... logically you cannot integrate the result of fft().
  3 Comments
Walter Roberson
Walter Roberson on 3 Apr 2025
Discrete Time Fourier Transform is not a continuous function of frequency: it is inherently discrete frequency.
Paul
Paul on 3 Apr 2025
Edited: Paul on 3 Apr 2025
No, that's not correct.
The Discrete Fourier Transform is a function of discrete frequency (though the definition on the Wikipedia page uses the integers k as the independent variable). To be more precise, the independent variable is defined only at discrete points on a finite domain; some treatments would define the independent variable at discrete points on an infinite domain (e.g. the integers).
The Discrete Time Fourier Transform is a function of continuous frequency (omega) that covers the entire real line. If there is a source that defines the DTFT with an independent variable that is discrete, I'd really like to see it.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!