Best way to filter a Matrix

1 次查看(过去 30 天)
I have the postion, velocity and acceleration data from a subject walking. Each variable is a matrix with each column representing a step and each row representing a measurement. However, there are some bad values where VZ didn't record a position (ie 1; 2; 3; 0; 5) or the vaue is way off(ie 1; 2; 3; 1256; 5). I would like to create vectors for average step values for position, velocity and acceleration.
Whats the best way to create the vectors without the bad values?
I am having trouble with the finding the bad values and making the dimensions of the columns agree. Any help is greatly appreciated... Thanks.

采纳的回答

Paulo Silva
Paulo Silva 2011-6-29
Maybe this can help you start with a smooth algorithm
po=[1 2 3 10 4 5 100 6 7 8 9 0 10 11 12 0 13 14 15 16]
p=po;
v=diff(p);
vp=find(abs(v)>2);
vp=vp(1:2:end);
p(vp+1)=(p(vp+2)+p(vp))/2;
t=1:numel(p);
plot(t,po,t,p)
legend('Measurements','Filtered measurements')
p
  3 个评论
Daniel
Daniel 2011-7-5
Thank you for yor help... I was unabe to replace bad values with averages. I placed limits on the variables and it worked okay.
Paulo Silva
Paulo Silva 2011-7-5
I just remember something that might be useful for the same purpose, it's the rate limiter from simulink, http://www.mathworks.com/help/toolbox/simulink/slref/ratelimiter.html , you can use the documentation formulas on your problem.

请先登录,再进行评论。

更多回答(2 个)

Sean de Wolski
Sean de Wolski 2011-6-29
Do you have the curve fitting toolbox? If so, look at:
doc smooth
specifically the 'rlowess' option.
Are all three signals recorded or do you just have acceleration or just position? Assuming you only have one of the signals, do the smoothing before any differentiation or integration.
  1 个评论
Daniel
Daniel 2011-6-29
I do not have the curve fitting toolbox...
I have position, velocity and acceleration data. I was not present at the recording. When I try to filter the data before other calculations (sparating the data by step and task) it takes longer and I run into the same problems.

请先登录,再进行评论。


Andrei Bobrov
Andrei Bobrov 2011-6-30
my variant
pf = [po(1)-1 po po(end)+1];
p = median(pf(bsxfun(@plus,1:3,(0:length(pf)-3)')),2);
  1 个评论
Daniel
Daniel 2011-6-30
I am using your code and the code posted above. It is tricky because there can be multiple consecutive bad values.
http://i3.photobucket.com/albums/y80/griffdrc/Graph.jpg
I need to creat graphs like the ones in Figure C and D.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by