LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

help on 2d array

Hi, I am trying to make a 2D array and then insert random numbers into it through a while loop using shift registers. I then want to store the 2D array into "Data 2" table.
 
I don't know why but the 2D array does not get initialzed... I read the documentation, but it's no help. Can anyone tell me what's going on?
 
A screenshot of my VI is below.
 
Thanks!
Ke
0 Kudos
Message 1 of 5
(2,879 Views)
The way you are initializeing your array you are only getting a 1D array of two elements.  Expand the VI (hover near the bottom and click and drag it down) to expand for more dimentions.
Also your Boolean is outside the while loop.  Move it inside so you can stop the loop.
Message 2 of 5
(2,865 Views)
Well, I'm afraid you've got a bunch of problems:

  1. You're creating a 1D array outside the loop, not a 2D array. Consequently, the Insert Into Array function is just going to increase the size of your 1D array. So, at the start it's a 1D array with 2 elements. After the first iteration it's a 1D array with 4 elements. After the second iteration it's a 1D array with 6 elements, etc. You need to expand the "Initialize Array" function to have it create a 2D array. Put the cursor at the bottom of the icon until you get a double-arrow cursor and then drag the bottom of the icon down to add another input terminal. This will allow you to specify the initial size of the second dimension. The LabVIEW User Manual has the details on this.
  2. You're initializaing an array of integers, but trying to write floating point numbers into the array, so you're going to get data coercion.
  3. The boolean control needs to be inside the loop otherwise it only gets read once, at the start of the program.
  4. You don't have anything wired to the table. You need to wire the loop's output shift register to one of number->string functions and then that function's output to the table.


Edit: Sorry about the double answer: Posted at the same time as previous post.

Message Edited by smercurio_fc on 10-20-2006 11:09 AM

Message 3 of 5
(2,863 Views)

You could try using nested FOR loops to generate a 2D array of random numbers.  Wire the N terminal of the FOR loop to set you array dimensions.

Message Edited by paulmw on 10-20-2006 11:13 AM

Message 4 of 5
(2,860 Views)

Hi guys,

Thanks for the reply, I think I know how to correct it now 🙂

Ke

0 Kudos
Message 5 of 5
(2,849 Views)