フィルターのクリア

delete duplicated rows, (with saving some data)

1 回表示 (過去 30 日間)
Amr Hashem
Amr Hashem 2015 年 5 月 16 日
コメント済み: Amr Hashem 2015 年 5 月 16 日
i have this table (size:8*2): ( 1st column has numbers some of them is duplicated)
434846 x
434846 y
434850 f
434854 s
434859 A
434859 B
434859 C
434862 N
i want to delete the duplicated row but save the (2th column & or 3rd) in the origin number to form a table (size:5*3) like this:
434846 x y
434850 f
434854 s
434859 A B C
434862 N
how i can do this?

採用された回答

Star Strider
Star Strider 2015 年 5 月 16 日
編集済み: Star Strider 2015 年 5 月 16 日
This works:
A = {434846 'x'
434846 'y'
434850 'f'
434854 's'
434859 'A'
434859 'B'
434859 'C'
434862 'N'};
%
A1 = cell2mat(A(:,1));
[Au,ia,ic] = unique(A1);
for k1 = 1:size(Au,1)
A2{k1,:} = {Au(k1) A(k1==ic,2)};
end
EDIT — Print loop for ‘A2’:
for k1 = 1:size(A2,1)
fprintf(1, ['\n%d\t' repmat('%s ',1, length(A2{k1}{2}))], A2{k1}{1}, char(A2{k1}{2}))
end
fprintf(1, '\n')
produces:
434846 xy
434850 f
434854 s
434859 ABC
434862 N
  1 件のコメント
Amr Hashem
Amr Hashem 2015 年 5 月 16 日
thank you
it works
but it put the duplicated text over eachother
it gives me:
434846 CCOOMMPPLLAAIINNAANNTT AALLLLEEGGEEDD TTHHAATT
434850 COMPLAINANT ALLEGED THAT DURING A ROUTINE SHIFT CHECK BY A
434854 COMPLAINANT ALLEGED THAT DURING A ROUTINE SHIFT CHECK BY A
434859 CVAOECMRCPIELFSAISIE NDPA ONRRTET P AOBLRRLTOGEKEDED N M.TA .
434862 COMPLAINANT ALLEGED THAT
no 1,3 had duplicated texts
how i can seperate the text to appear like this ?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by