function idx = indexOf(value, x)
%INDEXOF Index of a specified value in a vector
%   idx = indexOf(value, x) returns the index of the first
%   element in x equal to value. The index 0 is returned 
%   if there is no element in x equal to value.

idx = 0;
for i = 1:numel(x)
    xi = x(i);
    if xi == value
        idx = i;
        break;    % needed to return the first occurrence of value
    end
end



