LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

removing zeros from data stream

Hi

 

I have incoming data (plz see attached diagram which shows the 2 states of the for loop '0' and default) which is a 1-D array of 64 bit real data .....it goes through the loop which removes zeros from the array.

 

As I have 3 elements in the 1-D array (call them x,y,z ), the loop works very well for all values of 'y' and 'z' .

 

However when x gets towards 1 and below say 10e-3 (it never is a negative number), the loop is rounding everything to 1 and then when the value gets between 1 and 0 (10e-3 for example) the loop leaves it out altogether and I just get y,z  values saved.

 

Plz help me sort this out .

 

Cheers

 

Baz

Download All
0 Kudos
Message 1 of 8
(3,390 Views)

I dont exactly get what u r trying to do, but i can tell you need to adapt your output to the source.

0 Kudos
Message 2 of 8
(3,382 Views)

I'm not sure if I understand correctly. You're wiring a floating point number to the case selector. Case structures only work with integers, so your floating point number is converted to integer, rounding to the next available value. So a value < 0.5 will be rounded to 0 and will be removed by your code.

If your values are really 0 you might want to insert a "=0?" primitive and wire this to the case structure. Else you can use "In Range and Coerce" to see if your value is within a certain range, e.g. -1e-10..1e-10 and skip the value for that range.

 

0 Kudos
Message 3 of 8
(3,379 Views)

Hi Dan_U

 

I think you understand perfectly ...that is exactly what is happening ...

 

None of my values should ever be equal to zero.

 

How would I modify the structure to allow values to come through and be saved. Sorry I am a noob so need a bit of a spoon-feed.

 

Regards

 

B

 

0 Kudos
Message 4 of 8
(3,375 Views)

Instead of wiring the floating point value to the case structure, use =0? and wire the resulting boolean to the case structure.

remove_0.png

Again, this will only work when the values are really 0. Else you might need a range check to decide whether you have to keep or remove the element.

0 Kudos
Message 5 of 8
(3,368 Views)

I think you will need to define a tolerance and test against that. You should never test for exact equality when working with floating point numbers.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 8
(3,349 Views)

Thanks for all the replies guys. In terms of an exact quantity, I think you can define it as such since the computer will spit out 0.00E00 for every zero ...maybe you can define zero in this way ?

 

I will give it a try and let you guys know

 

Regards

 

B

0 Kudos
Message 7 of 8
(3,332 Views)

If you want a tolerance comparison, try the attached VI.  I rewrote it from one in vi.lib after an earlier post.

0 Kudos
Message 8 of 8
(3,307 Views)