12-16-2019 09:14 AM
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.
Solved! Go to Solution.
12-16-2019 09:34 AM
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.
12-16-2019 09:59 AM
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)?
12-16-2019 10:02 AM
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. )
12-16-2019 10:02 AM
@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.
12-16-2019 10:11 AM
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 🙂