LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I conditionally remove elements from an array

Solved!
Go to solution

Hi,

I have a 1D array of values (about 1000 elements) which I need to remove some elements from. I need to calculate the mean and standard deviation of the array and if any of the array values are outside some multiple of the standard deviation away from the mean, I need to delete those elements and then relalculate the new mean. I'm not entirely sure how to go about doing this.

Thanks for any advice.

0 Kudos
Message 1 of 5
(4,861 Views)

For Loop, or while loop.

 

Shift register to maintain array between iterations.

 

Comparison and case structure.

 

Delete from Array in case when you need to delete.  Wire the array through in the case where you don't need to delete.

0 Kudos
Message 2 of 5
(4,857 Views)

I'm not entirely sure how to do the comparison. If I wire the array into the loop, then my comparison gives me an array of booleans which I can't connect to the case structure. If I index my array into the loop, then I can't use the delete from array function.

Thanks for the help

0 Kudos
Message 3 of 5
(4,846 Views)

You need to keep an index value in a shift register.  If you deleted an element, pass the index straight through.  If you did not delete an element, then you need to increment the index.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 5
(4,842 Views)
Solution
Accepted by topic author suneilr

Its simple to have a condition and remove the elements that doesn't meet the condition. Check the attached vi for an example.

 

Conditional delete.png

 

Good Luck

-----

The best solution is the one you find it by yourself
Message 5 of 5
(4,838 Views)