Filter löschen
Filter löschen

Best way to filter a Matrix

1 Ansicht (letzte 30 Tage)
Daniel
Daniel am 29 Jun. 2011
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.

Akzeptierte Antwort

Paulo Silva
Paulo Silva am 29 Jun. 2011
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 Kommentare
Daniel
Daniel am 5 Jul. 2011
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 am 5 Jul. 2011
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Sean de Wolski
Sean de Wolski am 29 Jun. 2011
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 Kommentar
Daniel
Daniel am 29 Jun. 2011
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.

Melden Sie sich an, um zu kommentieren.


Andrei Bobrov
Andrei Bobrov am 30 Jun. 2011
my variant
pf = [po(1)-1 po po(end)+1];
p = median(pf(bsxfun(@plus,1:3,(0:length(pf)-3)')),2);
  1 Kommentar
Daniel
Daniel am 30 Jun. 2011
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.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by