Appropriate window from accelerometer data

10 次查看(过去 30 天)
I am attempting to put my data through the fat function however, it seems that due to high spikes at the ends I may need to use a window or/and a low pass filter. I am completely new to this and I am unsure how to go about this. For example should I use the Blackman-Harris filter? If I do how do I work the value for N etc.
Sorry for such a basic question
Bran

回答(8 个)

Wayne King
Wayne King 2013-12-17
By the "fat" function, did you really mean fft()?
The question is, do you really need the data at the ends? If you trying to estimate periodicities in the data, then maybe you just don't need that data. Especially if you have a sufficient number of data points, you can just select a representative section of the data where the data is "stationary".
If you want to try windowing, you simply form a window function equal in length to your data and then multiply your data element by element
x = randn(1500,1);
win = hamming(1500);
y = x.*win;
I would not worry too much about the type of window -- a Blackman window is just
win = blackman(1500);
Also, since you have the Signal Processing Toolbox, why not just periodogram() instead of fft()?

Bran
Bran 2013-12-17
Hi there,
I have been thinking about my problem in more depth and have realised that I may need to preprocess my data. Basically my data is from an older person walking for a period of time then going down some steps before doing some light exercise. If I want to pick out these different activities would it be ebtter for me to divide up my data before carrying out the FFt on several parts. So;
X = DATA
%Splitting up the data into roughly three sections
Then applying the hamming window on each section followed by the FFT?

Wayne King
Wayne King 2013-12-17
If the data is nonstationary, then:
Yes, if you can clearly section the data by condition, you can divide your data into sections and then window each section followed by Fourier analysis.
Or you can do a spectrogram.
It sounds like if you have 3 experimental conditions where you know the start and stop times of data collection, then the former would work well.

Bran
Bran 2013-12-18
Hi there thanks so much for the suggestion, When I apply this method though I get the error message saying that the dimensions must agree; after y = x.*win Any ideas?
  2 个评论
Wayne King
Wayne King 2013-12-18
I'm assuming that you your x is a row vector because window is a column vector, try
x = x';
y = x.*win;
Bran
Bran 2013-12-19
Thanks Wayne I had done a silly mistake this has been solved now :)

请先登录,再进行评论。


Bran
Bran 2013-12-19
Hi there I was wondering if you could have a look at the graph I have made from one of the sections from my data. The large spikes at the start and end make me think the hanning window has not worked however, I may be interpreting my data incorrectly.

Bran
Bran 2013-12-19
编辑:Wayne King 2013-12-19
Also can I also say that my code so far is as follows;
x1 = data (from section1 a period of walking and jumping)
y1 = x1.*win
fs = 60 (I sampled at 60Hz)
Fn = 60/2
NFFT = 2.^(ceil(log(length(x1)/log(2)))
FFTX = fft(y1, NFFT)
N = length(y1)
freq = linspace(0,Fs,N)
plot(freq,abs(FFTX))
I note that this does not work for me because supposedly the dimensions do not agree plot(abs(FFTX)) gives th eplot that I have included
  1 个评论
Wayne King
Wayne King 2013-12-19
I don't see any plot of your data attached anywhere.
Yes, the above code will not work because you are padding the fft() but then you create a frequency vector just based on the length of the signal, so those lengths will not match.

请先登录,再进行评论。


Bran
Bran 2013-12-19
Also its important for me to add that all my plots from the various sections of data look the same with just large spikes at the start and finish? Any ideas

Bran
Bran 2013-12-19
Also would perhaps a low pass filter work?

Community Treasure Hunt

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

Start Hunting!

Translated by