LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

duplicate borders

Solved!
Go to solution

I want to duplicate all the borders of my 2d array a few times so I get a coppy of all outside rows and cols next to them.

Example:

Original:    1     2    3    4

(4-4)          5     6    7    8

                9    10   11  12

                13  14   15  16

 

Output:    1     1      2       3     4     4

6-6          1     1      2       3     4     4

               5     5      6       7     8    8

               9     9     10     11    12   12

              13   13     14    15    16   16

              13   13     14    15    16   16

(In the middle of the output array you find the origingal array)

I need to get up to 6 kopies of the borders.
So 6 kopie col than the original array and again 6 kopie col.

Same for the rows.

(example has 1 kopie col than the original array and again 1 kopie col.)

 

0 Kudos
Message 1 of 10
(3,041 Views)

Hi

 

A partial solution may be as shown below

 

duplicate border.gif

0 Kudos
Message 2 of 10
(3,025 Views)

There are many ways obviously, this is slightly long winded. But will do the job.

border.png


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 3 of 10
(3,020 Views)

Indeed this does the job as in the example.
But I have a 2d array whit random numers as input.
I don't know what the value of the element will be.

What makes it a lot more difficult...

 

It also can be this:

 

Original:    10      23    133    44

(4-4)          58     16     37     80

                999    10    131    72

                13      54    50      56

 

Output:   

(6-6)         10    10    23    133    44   44

                10    10    23    133   44    44

                58    58    16     37    80    80

                999  999  10     131   72    72 

                13    13    54     50    56    56 

                13    13    54     50    56    56 

0 Kudos
Message 4 of 10
(2,996 Views)

The code I posted will still work for random numbers.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 5 of 10
(2,994 Views)

I'm thinking it looks like recursion, but I made this instead:

 

Example_VI_BD.png

 

Note - the little For loops were the beginnings of a recursive solution that would work for 2D and 1D arrays.  I had Matrix and Array size and decrement primitives.

 

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 6 of 10
(2,993 Views)

Thanks for you help guy (.aCe.,jcarmody )!
Both solutions work out!

0 Kudos
Message 7 of 10
(2,977 Views)
Solution
Accepted by koekie

@koekie wrote:

[...]

I need to get up to 6 kopies of the borders.
So 6 kopie col than the original array and again 6 kopie col.

Same for the rows.

(example has 1 kopie col than the original array and again 1 kopie col.)

 


Is this what you're looking for?

 

Example_VI.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 8 of 10
(2,973 Views)

Yes indeed, that was what I need! 🙂

0 Kudos
Message 9 of 10
(2,959 Views)

I'm curious about why you need this.  What's it for?

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 10 of 10
(2,932 Views)