Matlab - Signal Noise Removal

后端 未结 5 735
独厮守ぢ
独厮守ぢ 2021-02-04 16:11

I have a vector of data, which contains integers in the range -20 20.

Bellow is a plot with the values:

\"en

5条回答
  •  别那么骄傲
    2021-02-04 16:50

    One approach to detect outliers is to use the three standard deviation rule. An example:

    %# some random data resembling yours
    x = randn(100,1);
    x(75) = -14;
    subplot(211), plot(x)
    
    %# tone down the noisy points
    mu = mean(x); sd = std(x); Z = 3;
    idx = ( abs(x-mu) > Z*sd );         %# outliers
    x(idx) = Z*sd .* sign(x(idx));      %# cap values at 3*STD(X)
    subplot(212), plot(x)
    

    enter image description here


    EDIT:

    It seems I misunderstood the goal here. If you want to do the opposite, maybe something like this instead:

    %# some random data resembling yours
    x = randn(100,1);
    x(75) = -14; x(25) = 20;
    subplot(211), plot(x)
    
    %# zero out everything but the high peaks
    mu = mean(x); sd = std(x); Z = 3;
    x( abs(x-mu) < Z*sd ) = 0;
    subplot(212), plot(x)
    

    enter image description here

提交回复
热议问题