LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Replace each 0 and 1 in an array with n number of 0s and 1s

Hi , could you please help me with this. Lets say I have this array

 

01001

 

and I want to replace each 1 and 0 with 2  ( might be 10000)  number of0s and 1s. so the result is

 

0011000011

 

Could you please help me to implement this in LV . As mentioend I should be able to repeat the bits as many time as specified . 2 times or 100000 times

Thanks

0 Kudos
Message 1 of 8
(2,772 Views)

This sounds like homework, but i'll give you a hint -

 

You need to iterate through the array and create a seperate array based on the individual elements. To do that, you'll need a for loop, a case structure, initialize array, and build array.

 

You should be able to take it from here...

Philip
CLD
0 Kudos
Message 2 of 8
(2,766 Views)

VI Attached.  Pretty easy logic to claim help  :[  I would suggest u to learn LabVIEW fundamentals. Read the help context and pratice with examples already shipped. 🙂

 

 

Message 3 of 8
(2,744 Views)

@p-rose wrote:
...To do that, you'll need a for loop, a case structure, initialize array, and build array.

Two for-loops will do, actually Smiley Tongue

Homework2.png

Message 4 of 8
(2,730 Views)

Or you could just interleave the array with a copy of itself. See attachment.

Best regards,

Jarle Ekanger, MSc, PhD, CLD
Flow Design Bureau AS

- "The resistance of wires in LabVIEW is not dependent on their length."
0 Kudos
Message 5 of 8
(2,720 Views)

I would use Initialize Array.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 8
(2,701 Views)

Or, if you want to be fancy, turn the digit array into a string, use search-and-replace (2X) to add your digits, then turn the resulting string back into a number array.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 7 of 8
(2,683 Views)

Most cleaner and simple solution has been posted by crossrulz

0 Kudos
Message 8 of 8
(2,661 Views)