LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to make 1d to 2d subvi

Solved!
Go to solution

Hello all.  I am trying to make a subVI that will convert a numerical 1d array into a 2d array.  I want the VI to be able to accept different dimensions for the 2d array and be able to adjust accordingly.  I tried to use the Reshape Array function, but I get an error if the input and output arrays do not have the same dimensions.

 

I have also used nested For Loops, which seem more successful, except I can't get the columns to update correctly.  I know the reason for this is because I don't know how to increment the inner loop and insert it into the array.  I'm not sure if I should use a local variable for the 2d array and put it inside the inner loop.

 

I have both versions (Reshape Array and nested For Loops) in this program.  I will use whichever works and get rid of the other one.

 

I'm trying not to use Build Array since I read that Build Array makes a copy of the array each time it runs.  I may be doing the same thing with what I am doing, but I don't know.

0 Kudos
Message 1 of 3
(1,376 Views)
Solution
Accepted by topic author Dhouston

Hi Dhouston,

 


@Dhouston wrote:

Hello all.  I am trying to make a subVI that will convert a numerical 1d array into a 2d array.  I want the VI to be able to accept different dimensions for the 2d array and be able to adjust accordingly.  I tried to use the Reshape Array function, but I get an error if the input and output arrays do not have the same dimensions.


Because your output array is labelled "2D array", but it is a 3D array - which is shown in the context help when you move the mouse over the broken wire!

 

Why are those #rows and #columns control set to I8 representation? After correcting the error(s) your VI should look like this:

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 3
(1,372 Views)

Yep, that solves the problem.  Thanks!

0 Kudos
Message 3 of 3
(1,345 Views)