11-29-2011 05:52 AM
Greetings everyone,
I need a vi such as I have 16 elements 1D array 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 I want an array like this
1 2 3 4
8 7 6 5
9 10 11 12
16 15 14 13
I mean the odd indexes should be transpozed. And thenumber of elements of the first array will be arbitrary such as 2500 and this 2D array will be 50x50.
Thank You
11-29-2011 07:56 AM
You can do that with a For loop and a shift register.
1) Init the SR for the proper size
2) Use the N of the For Loop to control the number of iterations based on the math you used to init your array.
3) Use Quotient Remander on the indx count with a divider of "2" to decide if its odd and then use an inner For loop to do "replace Elelemnt" with increasing indexes or decreasing indexes (subtract index from max minus 1).
There are many variations that can pull this off. I suggest comparing various methods for speed.
Post bakc with code images or snippets if you get stuck.
Ben
11-29-2011 08:11 AM
Homework?
Especially when someone starts off with "I need a VI", instead of "any suggestions on the best way to ...".
11-29-2011 08:17 AM
@smercurio_fc wrote:
Homework?
Especially when someone starts off with "I need a VI", instead of "any suggestions on the best way to ...".
Good point.
I just recognized the Q as what is required to convert a raster scan data set for display in 3D.
Ben
11-29-2011 04:14 PM
I am working on galvo mirror scanner and I am getting 2500 datas for one scan and, I have to organize the datas which comes from Analog input like I said. I hope I am clear now. Thank you for replies.
11-29-2011 04:17 PM
I will organize the datas and produce a intensity graph by using the matrix which I produced.
11-29-2011 05:13 PM - edited 11-29-2011 05:14 PM
OK, so not homework. ![]()
Have you tried what Ben suggested? It's pretty straightforward.
12-19-2011 07:19 AM
I have solved my problem like this thank you for everyone.
12-19-2011 08:02 AM
Well, that's one way to do it. You have several unnecessary and expensive array operations. Deleting and inserting array elements should be at the bottom of the list of array functions to use. Replace Array Subset, as mentioned before, is preferred since it minimized memory re-allocations. Also, if you reshape the array into a 2D array to begin with you can use auto-indexing and use the shift register to give you the new array, rather than the way you're doing it now which is to create a new array out of the for-loop. Attached is a simpler method.