08-14-2009 07:06 PM
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!!!
08-14-2009 07:08 PM
08-14-2009 07:44 PM
08-14-2009 08:14 PM
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.
08-14-2009 11:30 PM - edited 08-14-2009 11:31 PM
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....
