How to take the engineering FFT (magnitude spectrum scaled correctly) of Signal in Matlab?

25 views (last 30 days)
Hi All
the fft function in matlab gives a theoretical mathematical fft of the signal, and is not scaled to units and is real immaginary and not amplitude-frequency
I think in better terms, I want to plot the amplitude spectrum of the signal,, with the X axis being the frequencies of the input signal.
is there an alternative way of fft to do this ? and is the following link correct?
for example if this is my signal
using the code in the link I get
which its extremums do not meet the extremums of the time signal
  8 Comments
farzad
farzad on 30 Nov 2020
It was not possible to attach the signal file here I dont know why. It is an xlsx file of 2.8 MB. but does not get attached. I will add the code to the question as well. I have tried both of these. you can generate a random signal and check with it. my problem is not the signal
function [frq, amp] = simpleFFT(signal)
n = length(signal);
%generate the vector of frequencies
halfn = floor(n / 2)+1;
deltaf = 1 / ( n / ScanRate);
frq = (0:(halfn-1)) * deltaf;
z = fft(signal, n); %do the actual work
x=signal(:,1);
xFFT = abs(fft(x))/length(x);
amp = abs(fft(x).^2);
end
function [frq, amp] = simpleFFT(signal,ScanRate)
N=length(signal);
N1=2^nextpow2(N);
X=fft(signal,N1);
X=X(1:N1/2);%Discard Half of Points
X_mag=abs(X); %Magnitude Spectrum
X_phase=phase(X); %Phase Spectrum
frq=ScanRate*(0:N1/2-1)/N1; %Frequency axis
amp= X_mag/N1;
end

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 30 Nov 2020
The unit for the y axis of the discrete fft is the original unit per hertz. You need to integrate it over frequency to get the original unit.

Community Treasure Hunt

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

Start Hunting!