I am writing a code, where I want to check a `vector array` elements and check if the present element equal the previous `x(m)=x(m+1)`, then delete it , if not keep it in the array ... How to do that?

Here, what I tried to do:

```
vg=vg1(441777:448207);

j=zeros(size(vg));

for m=1:6431;
    if m+1<6432
        if vg(m)==vg(m+1)
            j(m)=[];
        else
            j(m)=vg(m);
        end
    end
end  

```

But it is not working and it gives error,, So may I know how to do it?