LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can't insert 1d array of DBL into 2d array

I've got a program which calculates resistances given measured resistances and a temperature range.  It generates a 2d array of results (temperature and resistance) which is two columns wide and about 510 rows long.  I'm trying to write something that will take that array as input and write a new 2d array that's ten columns wide, 51 rows long, and has only the resistance values.  I've managed to write a loop that reads ten values from the resistance column and puts them in a 1d array, but whenever I try to insert the 1d array into a 2d array in another loop to handle the rows, I get an error message about connecting arrays of differing dimensions.  I've tried both "Replace subset" and "Insert into array" but they both give me the same message.

I'm using a shift register to make sure the final array is used in each loop iteration (so I'm always adding a row to the same array).  I tried using "Build Array" but that only overwrites the first row over and over again.

I've tried searching the forums for a solution but I haven't been able to open any of the demo vi's because I'm using 8.0.1 and most of the demos are written in a later version.  Help?
0 Kudos
Message 1 of 16
(6,473 Views)

kharris126,

On the Array pallet, look at the Reshape Array.vi.  Use index array to extract your resistance column, then wire this to reshape and specify 51 for first dimension (rows) and 10 for second dimension (columns).  You will need to resize the vi to add the second input.

-cb

0 Kudos
Message 2 of 16
(6,472 Views)
Hi kharris,
 
In your image, you're using Replace Array subset..  If you're inserting new values into an initialized, but empty array, I would use insert into array.  What you are missing is the 2D array to be wired at the top of the function.  See image below.
 


Message Edited by JoeLabView on 12-06-2007 03:01 PM
0 Kudos
Message 3 of 16
(6,470 Views)

One problem is that you don't have an original array going into the replace array subset function you have circled.

With doing any insert into array function, you will have to be careful with the array functions and may need to do transpositions here or there to make it work.  For example, you can't put a 1-D array of 10 rows and put it into a 10 column by 51 row array without doing a transpostion to make it a 10 column by 1 row array.   Any work you do will require that the one of the dimensions will match in size.  If you put a 2 row by 2 column array into a 10 row by 10 column array, which way does it insert, to the right or down?  What goes into the empty elements that get created in either the remainin column, or remaining rows?

0 Kudos
Message 4 of 16
(6,465 Views)
If you don't wire the 2D array to the top of the Insert Into Array function, it (the function) thinks that it's a 1D array.  Therefore if you wire the output of the Insert Into Array to a 2D indicator, you will get a broken wire (and an error message).
 
Is the image below what you were seeing?
 



Notice how I left the input of the Insert into array empty?

Let me clean up the picture and repost!



Message Edited by JoeLabView on 12-06-2007 03:06 PM
0 Kudos
Message 5 of 16
(6,464 Views)

Cleaner picture..



Message Edited by JoeLabView on 12-06-2007 03:12 PM
0 Kudos
Message 6 of 16
(6,455 Views)

10Degee is correct. Reshape array is the proper function. Here's a quick draft, see if it suits your purpose. 🙂

(It will even pad the last row if the number is not divisible by 10).



Message Edited by altenbach on 12-06-2007 12:19 PM
Message 7 of 16
(6,679 Views)
I'm trying the reshape array currently, but I'm reading all the other replies too.

I could have sworn I was passing in the 2d array I was using on the top of the "insert into" function so it was in a loop?  I guess not.  I've attached a screenshot showing my more usual results without removing any of the broken wires; you can see the output of "insert array" is still a 2d array, and that wiring the 2d array into the input of "insert into" hasn't forced it to recognize that it's 2d and not 1d.

I'm probably way behind the responses in this thread.  Heh.

Reshape array worked, but plugging it into the Word report crashed the program.  Back to the drawing board.
0 Kudos
Message 8 of 16
(6,674 Views)
LOL!! 😄
LOL!!
😄
 
 
sorry...
 
LOL!!!  😄 😄
 
You can't do that... Looping back like that is just not right!  LOL!!!  You'd be pulling a time warp!  😄 LOL!!
 
sorry...  it's a little funny... 😄  Thanks, I actually needed to laugh a bit..  LOL!!  😄
 
Even if you could loop back, you're actually looping back a 1D array, so at the top, you still don't have a 2D array, which does not solve the original error.
 
😄
 
   


Message Edited by JoeLabView on 12-06-2007 03:37 PM
0 Kudos
Message 9 of 16
(6,668 Views)
What, you're telling me Lab View can't warp time and space?  I demand a refund!

(Okay, now I'm embarrassed.  Heh.)
Message 10 of 16
(6,665 Views)