LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

swap elements in 2d array

Solved!
Go to solution

I'm looking for a way to swap a user-defined length of elements in a 2-dimensional array between rows. All of my efforts so far only take the elements and move them within the same row.

 

Basically I have a 2d array with 2 rows, and I want to take a few of the elements from one and put them in the other, getting a new array that has elements of both. This needs to be expandable to any number of rows.

Thanks for your help. 

0 Kudos
Message 1 of 17
(3,851 Views)

A quick example-

 

This will take Length elements from Start index and reverse the row that tha data is in.  e.g Start 1 length 2

 

0 1 2 3                     0 3 4 3

4 5 6 7    Maps to     4 9 0 7

8 9 0 1                     8 5 6 1

2 3 4 5                     2 1 2 5

 

Maybe not exactly what you want but some food for thought.  A Z delay FBN would allow shifting rather than reversal


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 17
(3,842 Views)

I'm sorry I'm not a very advanced user, can you explain in a bit more detail how something like that might be done?

0 Kudos
Message 3 of 17
(3,836 Views)

Oh, He77!

 

I, of course, meant to ATTACH the exampleSmiley Very HappySmiley Very Happy  That is on my work PCSmiley Sad  I'll post it first thig in the AM 

 

 

Sorry.


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 17
(3,822 Views)

Something like this? (see attached)

CLD Certified 2014
Download All
0 Kudos
Message 5 of 17
(3,811 Views)

pretty close.  I did it with nested IPE structures I'll post the example in an hour or so


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 17
(3,793 Views)

Like this... Simple.

CLD Certified 2014
Download All
0 Kudos
Message 7 of 17
(3,785 Views)
Solution
Accepted by topic author jgor

@ADrexelDragon wrote:

Like this... Simple.


The OP did require the ability to expand to additional rows.

 

This example shifts row data down by "Shift"

1.png


"Should be" isn't "Is" -Jay
Message 8 of 17
(3,780 Views)

Thanks I should be able to do a lot with your solution, Jeff. I've never used IPE structures before. I'll start figuring these out.

0 Kudos
Message 9 of 17
(3,766 Views)

Here is what I came up with. It allows for single element swapping.

CLD Certified 2014
Download All
0 Kudos
Message 10 of 17
(3,759 Views)