function IDX = allIndexesOf(value, x)
%ALLINDEXESOF Indexes of a specified value in a vector
%   IDX = allIndexesOf(value, x) returns the vector of 
%   indexes of all of the elements in x equal to 
%   value. The index 0 is returned if there is no 
%   element in x equal to value.

IDX = [];
for i = 1:numel(x)
    xi = x(i);
    if xi == value
        % concatenate i to IDX
        IDX = [IDX i];  
    end
end

if numel(IDX) == 0
    IDX = 0;
end



