# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Replace 1's with 0's if they are less than 900

I'm struggling with the last part of my solution. I have a 1D Array with 1's or 0's. As the title suggests I'm looking for multiple 1-sequences and if they are less than 900 1's in a row I would like to replace them with zeros.

What I already achieved is finding the start and end of each sequence with 1's and their index and forming a pair of them. So I'm already able to work with the correct indexes. I posted a picture of my last and final step where I want to replace the 1's with 0's. I go in with the first pair, go in another for loop which runs (end of 1's - start of 1's) times. And start to iterate from the start index these N times. But somehow this part does not work and I do not know why. In my notes it makes sense, but I have made an error somewhere. I would be really grateful for some good tips.

Message 1 of 6
(2,461 Views)
Solution
Accepted by topic author Shurican

## Re: Replace 1's with 0's if they are less than 900

Hi, Shurican!

You should use shift registers instead of tunnels for the array, passing your inner For loop. In your case, you see only the result of inner's loop last iteration.

Message 2 of 6
(2,432 Views)

## Re: Replace 1's with 0's if they are less than 900

Hi, Sam_Rudneff

Thanks for your Input I read about it and implemented the shift registers in my code. I was not aware that I need a shift register, but it works perfectly fine now!

As I thought I had to rise the number N by 1.

So in my old code it basically did what I meant to but only saved the last iteration of my inner loop (only one value was saved)?

Message 3 of 6
(2,411 Views)

## Re: Replace 1's with 0's if they are less than 900

So in my old code it basically did what I meant to but only saved the last iteration of my inner loop (only one value was saved)?

Exactly. )

Message 4 of 6
(2,406 Views)

## Re: Replace 1's with 0's if they are less than 900

@Shurican wrote:

So in my old code it basically did what I meant to but only saved the last iteration of my inner loop (only one value was saved)?

That is correct.  Specifically, the last iteration of your inner loop using the values from the last iteration of your outer loop.  Tunnels default to only outputting the last value.  Shift Registers are used to keep values from iteration to iteration.

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 5 of 6
(2,405 Views)

## Re: Replace 1's with 0's if they are less than 900

Thanks for the fast replies and help!

It was rather a newbie question, but I really understood how I have to use these shift registers in my future projects 🙂

Message 6 of 6
(2,394 Views)