LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I clone elements in a 1D array?

Solved!
Go to solution

I have an array that has single values of elements such as [1,2,3] and I want to convert it to the format [1,1,2,2,3,3]

 

I'm trying to use a for loop with 2 counts but for some reason it says that I have too many dimensions.

 

Attached is my image.

0 Kudos
Message 1 of 5
(3,420 Views)

Learn about For loops, indexing terminals (on the input side, they allow you to "step through" your array one element at a time, while on the output side, they "construct" an array for you).  This will certainly be covered in the LabVIEW tutorials available for free (except it does cost a little time and effort on your part).

 

Let me paraphrase your problem in a way that should suggest a simple (and extremely efficient) solution:

 

For every element of the input array, put two copies into the output array.  Hint -- you can do this with a single For loop with one other LabVIEW function (guess from which Palette) inside the loop.

 

Bob Schor

 

[Colleagues -- please let ylevental try to figure this out -- this is the best way to learn ...]

0 Kudos
Message 2 of 5
(3,405 Views)
Solution
Accepted by topic author ylevental

There is a simple primitive, Interleave 1D array that would do that for you.

 

Hope that works!

 

1.png

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

Wisdom is the principal thing; therefore get wisdom: and with all thy getting get understanding. Proverbs 4:7
Message 3 of 5
(3,396 Views)

Thanks!  I didn't even know this existed before you showed me 😄

0 Kudos
Message 4 of 5
(3,376 Views)

No problem, there are so many  functions in LabVIEW that its extremely hard to keep up, if not impossible!

 

God Bless!

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

Wisdom is the principal thing; therefore get wisdom: and with all thy getting get understanding. Proverbs 4:7
0 Kudos
Message 5 of 5
(3,368 Views)