Suppose I have data: x = [3,3,1,1,1,2,2,1,1,1,1]
I would like to have a way out:
y = [3,1,2,1]
With a unique function () I could get:
z = [3,1,2]
But, as you can see, in the end I missed the "one." So, I tried to write a loop, but I am not doing what I have to do. I expected it to remove one of the duplicate values, and the loop should ensure that only one value remains. However, the output is:
x = [3,3,1,1,2,1,1]
Cycle:
for i=1:length(x)
if x(i)==x(i+1)
x(i)=[];
end;
end;
Is there a way to generate output like in y? Where is the error in my loop?
source share