I have the vector numbers which has 6 elements from user input. I want to remove any duplicate value and replace it by another input (without the use of "unique" or similar).
I tried:
myvec=zeros(1,6);
disp('Choose numbers from 1 to 55')
for i=1:6
myvec(i)=input('');
if (find(myvec(i)<1 | myvec(i)>55))
disp('Enter new value')
myvec(i)=input('');
end
if myvec(i+1)==myvec(i)
myvec(i+1)==input('');
end
end
The problem is:
1) The statement below is correct?
if myvec(i+1)==myvec(i)
myvec(i+1)==input('');
end
2) When running it gives out of bounds because the vector length is 6 and I am trying to access i+1 .I tried to use the for loop from 2:7 but then it adds in the myvec vector the zero as first element.
Thank you!