LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to compare 3 values in array

Solved!
Go to solution

@altenbach wrote:

Of course there is a solution, but it involves more math if you don't want to touch the existing data. Currently we get some smoothing which seemed beneficial to me. It is well within the noise of your data.

 

You could re-use my last code, but replace the outlier with a linear inter of the two others for positions where the outlier is in the center of the three and ignore otherwise.

You could also do a difference of the current result and only retain the new data for points where the difference is above a certain threshold.

etc. etc.

 

Try it! 😄


Ok, I'll try but can u how to realize this C code in labview? Can I check the difference between original and filtered signal by simple subtract? but it must be done also in this for loop right? or search values bigger than x in resulted array but I require second for loop?

C code:

for (i=1; i < size ; i++)
{ 
if ( Y[i]>Y[i-1] && Y[i]>Y[i+1] ) 
    {  
        if(Y[i]>1.5*Y[i-1] && Y[i]>1.5*Y[i+1])
        {      Y[i] = (Y[i+1]+Y[i-1])/2; i1++;        }
       else  Y[i]=Y[i];
    } 
else 
         {  
             if(Y[i]<Y[i-1] && Y[i]<Y[i+1])  
            { 
                if(Y[i]<0.5*Y[i-1] && Y[i]<0.5*Y[i+1])
                     {Y[i] = (Y[i+1]+Y[i-1])/2; i2++;}
                else  Y[i]=Y[i];
            }
 else  Y[i]=Y[i];
} 
}

 

0 Kudos
Message 21 of 24
(406 Views)
0 Kudos
Message 22 of 24
(400 Views)

@altenbach wrote:

try this:

 

 


Looks really nice but I don't understand why it's not working with some signals? I attached them.Is it depends of Y scale?

With the others works great!

0 Kudos
Message 23 of 24
(395 Views)

You probably need to tune the threshold. Haven't looked at your data....

0 Kudos
Message 24 of 24
(386 Views)