LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Doubling size of 2D boolean array

Solved!
Go to solution

Hi there.

 

I have a 20x20 2D boolean array and need to convert this to a 40x40 2D boolean array. If the first element of the 20x20 array is a 1, the first two elements of the first and second line of the 40x40 array need to be a 1 as well.

Thanks in advance!

0 Kudos
Message 1 of 7
(3,418 Views)

 

dblarray.png

 

This assumes a 20x20 input array size. To be more generic, you would use the size of input array as inputs to the Reshape Array.

0 Kudos
Message 2 of 7
(3,412 Views)

Did you mean just the first element, or you want to scale all elements in the original array?  If you want to effectively double the array size such that every previous element becomes 4 identical elements in the larger array, you need more code than that.  One simple solution was recently posted: http://forums.ni.com/t5/LabVIEW/dublicate-array-elements/td-p/2215382

0 Kudos
Message 3 of 7
(3,399 Views)

@jdepypere wrote:

I have a 20x20 2D boolean array and need to convert this to a 40x40 2D boolean array. If the first element of the 20x20 array is a 1, the first two elements of the first and second line of the 40x40 array need to be a 1 as well.


Boolean elements are either true of false, they are never 1.

 

You are leaving out a lot of scenarios. For example what should happen if the first element is FALSE?

Do the other elements matter too or can they be random?

 

Please be much more specific. 😄

0 Kudos
Message 4 of 7
(3,393 Views)

Another guess: You want every element of the input array to be replaced by a 4-element (2x2) segment with all values equal to the input element and the 2x2 segments in the same relative postions as the elements in the input array.

 

Here is one way to do that.

 

Lynn

Message 5 of 7
(3,384 Views)
Solution
Accepted by topic author jdepypere

Or similar to the other thread:

 

I made it smaller, but the code stays the same....

 

Message 6 of 7
(3,379 Views)

That's a very clean code, thanks! Works as expected 🙂

0 Kudos
Message 7 of 7
(3,360 Views)