フィルターのクリア

Eliminate repeating values in column, but keep one set and append the following column's value to kept values in first column:

2 ビュー (過去 30 日間)
Need to convert matrix A(250000x2) to A(14x250000) where values in first column repeat. Values in second column next to repeated values from first column need to be appended to the rows corresponding to that repeated value (and repeated values removed). Basically shifting. I can use unique to pull the values from the first column along with their index, but I am having trouble finding a way to transfer those values "up". Any suggestions?
[14 #1; 13 #1;...;1 #1;14 #2; 13 #2;...;1 #2;...14 #n; 13 #n;...;1 #n]
to
[14 #1 #2...#n;13 #1 #2...#n;...;1 #1 #2...#n]

採用された回答

Ameer Hamza
Ameer Hamza 2018 年 5 月 25 日
Try
splitapply(@(x) {x}, A(:,2), findgroups(A(:, 1)));
  3 件のコメント
fernando aguirre
fernando aguirre 2018 年 5 月 25 日
It works like a charm! Thank you once again!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by