MATLAB: What wrong with the code

findMATLAB

I want to create a data structure to find unique unsorted values, from an initial vector. I am doing something wrong.
y = []
j =1
for i = 1:length(x)
z = sum(find(y == x(1)))
if z <1
y(j) = x(i)
j = j+1
end
end

Best Answer

I would subscript ‘x’ as ‘x(i)’ here, rather than using ‘x(1)’:
z = sum(find(y == x(i)))