필터 지우기
필터 지우기

How to give unique id to similar row

조회 수: 7 (최근 30일)
Hazim Nasir
Hazim Nasir 2018년 2월 8일
댓글: Star Strider 2018년 2월 8일
hi I would like to add third column to the array represents unique id for a similar rows in the array I will be grateful for any help and thank you in advance
# 30 10
# 30 191
# 30 10
# 45 206
# 30 191
# 45 206
# 45 206
# 155 206
# 155 206
# 170 191
# 155 206
# 170 11
# 170 191
# 170 11
  댓글 수: 3
Stephen23
Stephen23 2018년 2월 8일
@hazim78: what is your definition of "similar row" ?
Jos (10584)
Jos (10584) 2018년 2월 8일
What should the 3rd column look like?

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

채택된 답변

Star Strider
Star Strider 2018년 2월 8일
I am not certain what result you want.
The unique function might be an option:
A = [30 10
30 191
30 10
45 206
30 191
45 206
45 206
155 206
155 206
170 191
155 206
170 11
170 191
170 11];
[Au,~,ID] = unique(A, 'rows','stable');
Out = [A ID]
Out =
30 10 1
30 191 2
30 10 1
45 206 3
30 191 2
45 206 3
45 206 3
155 206 4
155 206 4
170 191 5
155 206 4
170 11 6
170 191 5
170 11 6
  댓글 수: 2
Hazim Nasir
Hazim Nasir 2018년 2월 8일
thank you Star that is what I need, Id for similar rows many thanks
Star Strider
Star Strider 2018년 2월 8일
As always, my pleasure.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by