Azzera filtri
Azzera filtri

Best way to filter a Matrix

4 visualizzazioni (ultimi 30 giorni)
Daniel
Daniel il 29 Giu 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.

Risposta accettata

Paulo Silva
Paulo Silva il 29 Giu 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 Commenti
Daniel
Daniel il 5 Lug 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 il 5 Lug 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.

Accedi per commentare.

Più risposte (2)

Sean de Wolski
Sean de Wolski il 29 Giu 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 Commento
Daniel
Daniel il 29 Giu 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.

Accedi per commentare.


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

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by