LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting Numbers less than a threshold from an Array

I have a 2D array that contains both neg and pos numbers, i'd like to remove the data below a set threshold.  I tried the examples with a conditional tunnel but it did not work for my data.  I have included my test code, i'd really appreciate some help with this one.

 

First order of business is to resize the array to a specified number of rows, removal of data based on threshold is the next part.

0 Kudos
Message 1 of 12
(5,927 Views)

You cannot delete individual elements of a 2D array, because 2D arrays must remain rectangular, not ragged. You can only delete entire rows or columns. You could replace all bad values with NaN (or some other sentinel value), for example.

 

On a sidenote:

  • "Array subset" is more appropriate than "delete from array", because all you need to wire is the start index.
  • You don't need to wired the array indices in this case. Keep it simpler.
0 Kudos
Message 2 of 12
(5,908 Views)

NaN might work the data is being displayed on an intensity chart, the issue is that my data has a value of -21474.8 that i'd really like to delete or change to NaN.  How do you replace data with NaN in Labview?  Usually i'm trying to get rid of the NaN's but they may come in handy in this case.

 

0 Kudos
Message 3 of 12
(5,900 Views)

An intensity graph does not skip NaN (unlike normal graphs). Would it be sufficient to replace them with zero?

 

To replace with NaN,  use a stack of two FOR loops and autoindex on all boundaries. Do the comparison in the inner loop and use a select node to modify.

 

ReplaceSOme.png

 

To replace with zeroes, you could even do a loop-free version.

0 Kudos
Message 4 of 12
(5,891 Views)

If the intensity chart won't handle NaN then zeros will be better.  How can that be done without a loop though?  

0 Kudos
Message 5 of 12
(5,876 Views)

@coolhandLV7 wrote:

If the intensity chart won't handle NaN then zeros will be better.  How can that be done without a loop though?  


Easilly

Coerce.png


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 12
(5,872 Views)

I tried this method but changed the NaN to a (0), it turned the entire array into (0)'s...  My array is a 10x10 and all of the "good" data is surrounded by junk.  I think the method you proposed would change the entire row to (0)'s if first element is above the threshold.  Is that what is happening?

 

There has to be a way to change individual elements without changing the dimension of the array, i can do it in Matlab so there has to be a way in labview.  

0 Kudos
Message 7 of 12
(5,868 Views)

Jeff's code will only coerce values that are <0, but since your threshold is -45, this is lossy. You could replace the "0" diagram constant with the actual threshold value (meaning all values below the threshold will have a value of the threshold. Is this acceptable?)

 

Here's what I might do:

 

 

Threshold.png

 

Message 8 of 12
(5,861 Views)

@altenbach wrote:

Jeff's code will only coerce values that are <0, but since your threshold is -45, this is lossy. You could replace the "0" diagram constant with the actual threshold value (meaning all values below the threshold will have a value of the threshold. Is this acceptable?)

 

Here's what I might do:

 

 

Threshold.png

 


The beauty of my code (which is loopless) is that the 0 constant  (Threshold) CAN be changed to a control and then use Altenbachs nested loop and Select to replace Value with Sentinel Value simply off of "Coerced ?" from the In Range and Coerce output.  It would even be savable as a *.vim and recurseble so that any dimentionality could be handled in the "Swap" loop


"Should be" isn't "Is" -Jay
0 Kudos
Message 9 of 12
(5,850 Views)

"In range&coerce" with a +Inf as upper limit is the same as "min&max.", just needs more diagram space. 😄

0 Kudos
Message 10 of 12
(5,837 Views)