LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Some question about 2D array

I have construct a 2D array with either one or zero and want to convert it into a boolean 2D array
Can anyone help me to solve it?
 
Also, for an array, i want to start with a fixed size(let say 8X32) 2D array with all zero 
and then the data can be changeable later, how can i do this?
 
Thank You!
0 Kudos
Message 1 of 8
(3,238 Views)

Hi,

This VI should answer your questions

Here, i am initially creating a numeric array, converting it to boolean( just by checking if the element is zero or not)

Later, on the run user can modify the array elements

You will observe that i am using a ring while adding to array.

All i am doing here is creating a ring -> giving its values as 0 and 1-> and later reading this ring text ->conveting it ot numeric ->and adding to array at the click of the 'add to array' button. you can select row/column at which u want to modify the entry.

To simplify, You can also just add a value from a numeric control directly.

Hope this helps

Regards

Dev

 

Message Edited by devchander on 01-09-2006 01:40 AM

Message Edited by devchander on 01-09-2006 01:58 AM

0 Kudos
Message 2 of 8
(3,241 Views)
Hi,

I simplifies devchanders example a little bit:
- LabView can do math with arrays, so you don't need for loops to check the 2d array
- why don't you use local variables here but property nodes?
- when you use property "ring.text" to convert to number, then you shouldn't use a "O" instead of an "0". And why not use the ring value itself?


Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 8
(3,227 Views)
Ouch!
 
It slipped my mind that 'not equal to zero' can take array input too! Smiley Mad must be getting balmy after a break! Smiley Wink
Thanks GerdW ! Smiley Happy
 
For some reason, i seem to prefer Property nodes over local vaiables! so i used property node, just like that!Smiley Tongue
 
 And that O instead of 0 was a Typo! Smiley Wink
 
Oh Yeah, ring value can be used directly
 
regards
Dev
 
 
 

Message Edited by devchander on 01-09-2006 03:01 AM

Message 4 of 8
(3,223 Views)
Just a reminder to be careful when using any equality operation on floating point numbers.  A floating point number can look like 0 without being the binary representation of identically 0, and therefore will not compare as you would expect.  Unless there is some reason they need to be DBL, you'd be better off making the numeric array an integer-based type.  If they have to be DBL, then it'd probably be safer to ask if it's > 0.5 instead of != 0.
Message 5 of 8
(3,208 Views)

Jeff has a point there!

This attached Vi will demonstrate how equal/not equal to zero may not give an expected result for dbl type

Regards
 
Dev
 
Message 6 of 8
(3,177 Views)

hi,

  I wanna ask how can i get data from a spreadsheet file to an array in labview so i can work on it????

  And then how can i export it to another file?

Newbie alert!!!

Pls help

0 Kudos
Message 7 of 8
(3,164 Views)
Hi,
 
Check out the Read from spreadsheet file function in LabVIEW for getting data from a spreadsheet file into an array in LabVIEW. You can now write the data to a file using Write File or Write to spreadsheet File functions.
 
Hope this helps,
Ankita
0 Kudos
Message 8 of 8
(3,140 Views)