Finding if a number repeats in a single row
Show older comments
How do I create a script that checks if a number comes up more than once in a single row. For example, lets say we have a single row x=[-1,0,1,2,3,4,5,1] Is there a script that starts at say (i=1 and ends at i=final number of x) that starts at i=1 and checks if -1 comes up again in x if it doesn't goes to i=2 and checks if 0 comes up in x again if it doesn't it then goes to i=3 and checks if 1 comes up in x again which it does then stops at that point which is i=3. An additional example if this didn't make sense would be take y=[0,4,5,6,1,2,2,9,12,15] it starts at i=1 to check if 0 comes up again which it doesnt, then goes to i=2 and checks if 4 comes up again which it doesnt then i=3 if 5 comes up again which it doesnt then i=4 to check if 6 comes up again which it doesnt then i=5 to check if 1 comes up again which it doesnt then i=6 to check if 2 comes up again which it does. I then stops at i=6.
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!