12-05-2018 01:12 PM
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.
12-05-2018 01:55 PM - edited 12-05-2018 02:01 PM
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:
12-05-2018 02:09 PM
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.
12-05-2018 02:17 PM - edited 12-05-2018 02:51 PM
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.
To replace with zeroes, you could even do a loop-free version.
12-05-2018 03:10 PM
If the intensity chart won't handle NaN then zeros will be better. How can that be done without a loop though?
12-05-2018 03:16 PM
@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
12-05-2018 03:30 PM
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.
12-05-2018 03:59 PM
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:
12-05-2018 05:08 PM - edited 12-05-2018 05:13 PM
@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:
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
12-05-2018 06:10 PM
"In range&coerce" with a +Inf as upper limit is the same as "min&max.", just needs more diagram space. 😄