MATLAB: How can I locate a number in a vector with out using the function find

columnsfindindexindexinglocationmatricesrowvector

I am trying to locate a number in vector with out using the function 'find'.is there a way i could do this?

Best Answer

Here is one easy way using indexing:
>> x = 5 % value to find
>> V = randi(9,1,10) % vector of values
V =
3 5 6 7 6 3 5 2 6 6
>> idx = 1:numel(V);
>> idx(V==x)
ans =
2 7
Related Question