Unique (partial) values

Hi all! I have a cell array (imported by xlsread) of this kind:
'0.000000000' '185.47.162.26'
'0.000658000' '185.47.169.249'
'0.000793000' '177.10.146.49'
'0.003146000' '185.47.162.26'
'0.006683000' '185.47.162.26'
Now...i'm interested to select only rows corresponding to the first unique values of second column. So...in this example i need the following output:
'0.000000000' '185.47.162.26'
'0.000658000' '185.47.169.249'
'0.000793000' '177.10.146.49'
Unique function seems not to support a feature like this. Can you help me? Thx in advance! Mario

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 9 月 30 日

0 投票

[~, idx] = unique(YourCellArray(:,2), 'stable');
output = YourCellArray(idx, :);

1 件のコメント

Mario
Mario 2017 年 9 月 30 日
thank you!!!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeFiles and Folders についてさらに検索

タグ

質問済み:

2017 年 9 月 30 日

コメント済み:

2017 年 9 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by