Filter löschen
Filter löschen

How to give unique id to similar row

7 Ansichten (letzte 30 Tage)
Hazim Nasir
Hazim Nasir am 8 Feb. 2018
Kommentiert: Star Strider am 8 Feb. 2018
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 Kommentare
Stephen23
Stephen23 am 8 Feb. 2018
@hazim78: what is your definition of "similar row" ?
Jos (10584)
Jos (10584) am 8 Feb. 2018
What should the 3rd column look like?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Star Strider
Star Strider am 8 Feb. 2018
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 Kommentare
Hazim Nasir
Hazim Nasir am 8 Feb. 2018
thank you Star that is what I need, Id for similar rows many thanks
Star Strider
Star Strider am 8 Feb. 2018
As always, my pleasure.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Types finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by