Syed - try the following
x = [1 1 2 2 3];
groupedData = arrayfun(@(y)find(x == y), unique(x), 'UniformOutput',false);
In the above, we use arrayfun to loop over each unique element of x and apply the function
which returns the indices of those elements of x that are identical to that unique element (the input y).