02-12-2019 08:24 AM
Hi
I am trying to make a vi that will get an array and check for each 2 consecutive elements if they are the same - if yes delete only one of them and move on to the next couple and check again.
for example :
input array : 16 2 67 128 10 10 42 55 10 10 10 10 22 33 10 03 22 55
output should be : 16 2 67 128 10 42 55 10 10 22 33 10 03 22 55
i will appreciate any help
thanks
Solved! Go to Solution.
02-12-2019 08:30 AM
Ben
02-12-2019 08:46 AM
Thanks but it is not what i need
the input is: 1626 7128 1010 4255 1010 1010 2233 1003 2255
the output from this function is : 1626 7128 1042 5522 3303
and i need it to be : 1626 7128 10 4255 10 10 2233 1003 2255
from every duplicated couple to take one
thanks
02-12-2019 08:53 AM - edited 02-12-2019 08:54 AM
A simple FOR loop with a conditional output tunnel and a Feedback Node (or shift register) will do the trick.
02-12-2019 09:09 AM
Thanks to you
but still not exactly what I need because if I have Input 01 10 10 10 10 02
I get out put : 01 10 02
And I want to get 01 10 10 02
from every two consecutive numbers to get one
(I know if it will be duplicated it would be an even number of times)
Thanks
02-12-2019 09:22 AM - edited 02-12-2019 09:27 AM
Hi nuvo,
so you want to keep a value
IF x[n] <> x[n-1] OR x[n-1] == x[n-2]
?
(Well, my expression is most probably not correct, but it's your task to define your requirement anyway. 🙂 )
All you need to do is to define your requirement in the correct way…
02-12-2019 09:23 AM
This is one of many ways to accomplish what you need. Assuming that the input array has always an even number of elements.
02-12-2019 09:35 AM - edited 02-12-2019 09:36 AM
@nuvo wrote:
but still not exactly what I need because
Then just add a little more logic to keep an element if the previous was thrown out.
02-12-2019 10:31 AM
@GerdW wrote:
...
(Well, my expression is most probably not correct, but it's your task to define your requirement anyway. 🙂 )
All you need to do is to define your requirement in the correct way…
Ditto that!
Quoting myself;
"The first step in solving a problem is clearly defining what the problem is."
Ben
11-13-2024 05:56 AM
Hey,
What the use of that NaN at the input of Feedback initializer.