What I'm trying to accomplish is the following:

I wish to create a vector of integers, from a relatively small range, and ensure that none of the integers will be followed by the same integer.

i.e., This is a "legal" vector:
[ 1 3 4 2 5 3 2 3 5 4 ]

and this is an "illegal" vector (since 5 follows 5):
[ 1 3 4 2 5 5 2 3 5 4 ]

I've experimented with `randi`, and all sorts of variations with `randperm`, and I always get stuck when i try to generate a vector of around 100 elements, from a small range (i.e., integers between 1 and 5).

The function just runs for too long.

Here's one of the attempts that i've made:

```
function result = nonRepeatingRand(top, count)

    result = randi(top, 1, count);

    while any(diff(result) == 0)
         result = randi(top, 1, count);    
    end

end

```

Any and all help will be much appreciated. Thanks !