CAT arguments dimensions are not consistent while applying a Despike Filter

1 Ansicht (letzte 30 Tage)
Hi all! i was applying a simple despike filter based on a median filter and got the above error message that CAT arguments dimensions are not consistent.
%extend data vector by n data points at both ends
xi = [flipud(x(1:n)); x; flipud(x(end-n+1:end))];
%apply order n median filter
xfilt = medfilt1(xi,n);
%difference to filterd data
dif = abs(xfilt(1+n:end-n)-x);
%number of spikes
nspike = sum(dif>lim);
%replace spikes with NaNs
x(dif>lim) = NaN;
xout = x;
Where x is the input data (in my case a 1290x6 array), n is order of median filter (n=3 detects spikes consisting of single data points only) and lim is the detection limit (which i set to 4), i.e spike if x(i)-x_filtered(i)>lim .
This filter wordke quite well with other data, i dont see the problem. Thanks for your help!
  2 Kommentare
xenon99942
xenon99942 am 8 Aug. 2017
The error was in line xi = [flipud(x(1:n)); x; flipud(x(end-n+1:end))];

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by