LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Copy 1d array into 2d array??

Hi I need to do following array copy operation from 1D to 2D array.

 

 

for (i=0;i<max; i++)

{

   for(j=0;j<max2; j++)

   {

      k = m*4;

     array2[i][j] = array1[k];

   }

}

 

Any idea?

 

Thank you!!!

0 Kudos
Message 1 of 5
(4,249 Views)
what is "m"?
0 Kudos
Message 2 of 5
(4,247 Views)
Let say m=2, some arbitrary value!!!
0 Kudos
Message 3 of 5
(4,241 Views)

Where exactly is the copying? All you're doing is creating a 2D array in which all the elements have the same value. This value is the value of a specific element from some other array. The Initialize Array function will give you an array with all the elements of a specific value.

 

To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

0 Kudos
Message 4 of 5
(4,233 Views)

smercurio_fc wrote:

Where exactly is the copying? All you're doing is creating a 2D array in which all the elements have the same value. This value is the value of a specific element from some other array. The Initialize Array function will give you an array with all the elements of a specific value.


I agree that this does not look right. Why would you need to recalculate k so many times in the inermost loop if it never changes? Shouldn't k=m*4 be calculated only once before the loops?

 

You would only need to do these calculations in the innermost loop if k somehow depends on i and j, and currently it does not.

 

Here's the near literal translation of your code, but I suspect there is probably more to it....

 

 

Message Edited by altenbach on 08-14-2009 09:31 PM
0 Kudos
Message 5 of 5
(4,214 Views)