Welcome to the World of Modelling and Simulation

What is Modelling?

This blog is all about system dynamics modelling and simulation applied in the engineering field, especially mechanical, electrical, and ...

A Short MATLAB Script for Spectrum Analysis or FFT

The following codes may be used for spectrum analysis for any vibration problems. The program is capable of isolating fundamental peaks from a noisy signal smoothly. It uses the MATLAB built-in Fast Fourier Transform (FFT) algorithm.

Codes for Spectrum Analysis (FFT):

NS=EFFORTS(:,1);                 % Data to Analyze
L=length(NS);
Fs=L;                            % Sample Rate
NFFT = 2^nextpow2(L);
F = Fs/2*linspace(0,1,NFFT/2+1);
win=hamming(L,'periodic');
Ywin=win.*NS;
X = fft(Ywin,NFFT)/L;            % MATLAB built-in FFT Algorithm
Xf=abs(X(1:NFFT/2+1));
Xf=Xf/max(Xf);                   % Normalizing Magnitude

plot(F,Xf)

No comments:

Post a Comment