How to combine repeated same value to a single value or variable
Show older comments
X=[3 5 ; 1 2 ; 5 6 ; 3 5 ] How to make like Y=[3 5; 1 2; 5 6] ie; representing [3 5] for single time rather displaying it twice
Answers (1)
Rik
on 12 Mar 2018
1 vote
3 Comments
RAJASEKAR S
on 12 Mar 2018
James Tursa
on 12 Mar 2018
See the 'rows' option.
Rik
on 12 Mar 2018
That is why the link leads you to the 'rows' flag example:
[C,ia,ic] = unique(A(:,1:2),'rows')
In your case:
X=[3 5 ; 1 2 ; 5 6 ; 3 5 ];
Y=unique(X,'rows','stable');
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!