MATLAB: I want to convert the output of transient analysis of cantilever beam from time domain to frequency domain, so i used the fft function as below. But i am not getting the correct answer. Please anyone can help me to solve this problem

MATLAB: I want to convert the output of transient analysis of cantilever beam from time domain to frequency domain, so i used the fft function as below. But i am not getting the correct answer. Please anyone can help me to solve this problem

Fs = 100;
T = 1/Fs;
a = load('C:UsersSiddeshaDesktopMATLABcant_transient3.txt');
y = a(:,3);
x = a(:,2);
figure(1)
plot(x,y)
L = length(y);
t = linspace (0, L-1, L)*T;
figure(2)
plot (Fs*t, y)
NFFT = 2^nextpow2(Fs);
absy = fft(y,NFFT)*L;
f = Fs/2*linspace(0,1,NFFT/2+1);
figure(3)
plot(f,2*abs(absy(1:NFFT/2+1)))

Best Answer

  • Hi Siddesha, please format your code by highlighting it, using the {}Code button and using ENTER if necessary to make individual lines of text.
    Anyway, this transform works out much better if you remove that ugly transient spike at the start of your time domain data, for example by inserting
    x = x(140:end); y = y(140:end);
    just after you create x and y. If you believe that the spike represents reality, then for the fft you are going to get pretty much what you got.
    For normalization, in the ‘absy’ definition I believe you should divide by L, not multiply by it. In fig. 2 you may want to do a plot of (t,y).
  • Add a Comment

    Your email address will not be published. Required fields are marked *