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).
1 Comment
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/351130-how-to-find-indices-of-similar-elements-in-a-vector#comment_473696
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/351130-how-to-find-indices-of-similar-elements-in-a-vector#comment_473696
Sign in to comment.