Problems with mathlab FFS
Problems with mathlab FFS
(OP)
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:
http://www.megafileupload.com/en/file/434206/MTbea...
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 :)
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:
http://www.megafileupload.com/en/file/434206/MTbea...
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 :)
RE: Problems with mathlab FFS
Cheers
Greg Locock
New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?
RE: Problems with mathlab FFS
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: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?
RE: Problems with mathlab FFS
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: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?
RE: Problems with mathlab FFS