필터 지우기
필터 지우기

sorting vector with duplicated values in it.

조회 수: 2 (최근 30일)
Andrea
Andrea 2012년 8월 24일
Hey All,
I have a vector that I want to sort but remove the duplicated values. I know I can do that with "unique"but I need to keep the number of repetitive valuessuch as this: a=[10 1 2 10 1 6 7 8 9 10 8 9 2 3 0];
I want to have 2 outputs like this:
a= [0 1 2 3 6 7 8 9 10];
Number=[1 2 2 1 1 1 2 2 3];

채택된 답변

Walter Roberson
Walter Roberson 2012년 8월 24일
unique_a = unique(a);
Number = histc(a, unique_a);
  댓글 수: 1
Andrea
Andrea 2012년 8월 24일
Thanks so much. It is perfect job in just 2 lines!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by