How can I apply a median filter to an signal (array) on Matlab? -


i have signal array (length m) , have noise of type salt , papper. applied low pass filter (lpf) , got result. want apply median filter signal , compare results apllying lpf).

i know function medfilt1(x,n), don't know n stands for.

the function is: y = medfilt1(x,x,blksz,dim) , want apply array raw_signal <5000x1double>.

for singal x raw_signal used

n=3 %the default number blksz= 5  dim = 1 %apply filter rows 

the output of function filtered signal, don't understand input n well. can explain me example.

n how many samples used compute each median. if signal [a b c d e f g], , n 3, second output median([a b c]). third median([b c d]), etc. first output little problematic because you'd try use non-existent sample, it's median([0 b]);

hand-wavy intuition advice follows (don't take exact description): in general, larger n, more filtering take place. consider this: if ever have 1 noise point (outlier) in 3 samples, median of other 2 estimate, , noise filtered. if have 2 noise points in particular group of 3 samples, median end choosing 1 of 2 noise points. n=5 catch it, perturb non-noisy points more.

don't mess blksz. text says, use if you're low on memory, , if are, pick blksz blksz x n x 8 (size of working matrix in bytes) somewhere between 1mb , 100mb. otherwise, leave out. , since have vector, dim=1 assumed, y = medfilt1(x,n) need.


Comments