10-03-2011 03:07 AM
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
10-03-2011 03:40 AM
I dont exactly get what u r trying to do, but i can tell you need to adapt your output to the source.
10-03-2011 03:53 AM
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.
10-03-2011 04:00 AM
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
10-03-2011 04:14 AM - edited 10-03-2011 04:15 AM
Instead of wiring the floating point value to the case structure, use =0? and wire the resulting boolean to the case structure.
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.
10-03-2011 09:51 AM
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.
10-03-2011 12:24 PM
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
10-04-2011 07:29 AM
If you want a tolerance comparison, try the attached VI. I rewrote it from one in vi.lib after an earlier post.