Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with mathlab FFS

Status
Not open for further replies.

REPresent

Electrical
Jul 12, 2013
2
Hello,

Im making research on humans gait and I found some troubles with matlab. I need given data in file pass through Fast fourier transformation. In given file taken column as X axe are samples of acceleration (which varies depending on movement). Frequence of device is 120Hz. In figure1 X axe is Time(s), Y axe is Acceleration(m/s^2) The main matter is how to make Spectrum of this Acceleration wave that in X axe would be Frequence and in Y axe would be Acceleration.



I inlcuded data text file named MTbeapsisukimo2:


Theres the code where I was trying to make X axe - as a frequence and Y axe as a Power:



accX=MTbeapsisukimo2:),9); %X Acceleration

accX=single(accX); % One Array


Fs=120; % Sampling frequency

t=0:1/Fs:22.945; % Time vector of 22.945 seconds

x=accX;

nfft=2754; % Length of FFT

% Take fft, padding with zeros so that length(X)is equal to nfft

X=fft(x,nfft);

% Take the magnitude of fft of x

mx=abs(X);

% Frequency vector

f=(0:nfft-1)*Fs/nfft;

% Generate the plot, title and labels.

figure(1)

plot(t,x)

title('Acceleration Wave Signal');

xlabel('Time (s)');

ylabel('Acceleration');

figure(2)

plot(f,mx)

title('Power Spectrum of a Acceleration Wave');

xlabel('Frequency (Hz)');

ylabel('Power');



I would be very thankfull for any consultation :)
 
Replies continue below

Recommended for you

Well that seems to work reasonably well, what is the issue?

You haven't calculated power by the way, that's linear units. power would be abs(X).*abs(X)

If you are puzzled by the calibration of the y axis read the help on fft, I'll admit I can't immediately tell you why it is exactly what it is. It is to do with the frequency resolution, and because half the energy in a double ended spectrum is above the Nyquist frequency

You seem to have worked out the frequency scaling correctly.



Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
Here's the correctly scaled fft

X=fft(x,nfft)/nfft*2;

nfft compensates for the way the energy is spread between bins, and the 2 is because of the Nyquist mirroring.

If you are going to do much of this I strongly recommend you read up on signal processing theory.

Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor