LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Odd Index Transpozed Arbitrary 1D to 2D

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

0 Kudos
Message 1 of 9
(3,611 Views)

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 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 9
(3,604 Views)

Homework?

 

Especially when someone starts off with "I need a VI", instead of "any suggestions on the best way to ...".

0 Kudos
Message 3 of 9
(3,599 Views)

@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 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 9
(3,596 Views)

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.

0 Kudos
Message 5 of 9
(3,587 Views)

I will organize the datas and produce a intensity graph by using the matrix which I produced.

0 Kudos
Message 6 of 9
(3,586 Views)

OK, so not homework. Smiley Wink

 

Have you tried what Ben suggested? It's pretty straightforward.

0 Kudos
Message 7 of 9
(3,582 Views)

I have solved my problem like this thank you for everyone.

0 Kudos
Message 8 of 9
(3,564 Views)

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.

Download All
Message 9 of 9
(3,557 Views)