Hello! I only found answers about how to find duplicate rows with "unique"..
I want to remove all duplicate values per row so every value per row is unique:
Matrix A:
[1 1 2
1 2 2
3 2 3]
Output:
[1 2
1 2
2 3]
Thanks in advance!

 採用された回答

Voss
Voss 2022 年 3 月 11 日

0 投票

A = [1 1 2; 1 2 2; 3 2 3];
A = num2cell(A,2);
B = cellfun(@unique,A,'UniformOutput',false);
try
B = cell2mat(B);
catch ME
% the arrays in the cells of B have different lengths
disp(ME.message);
end
disp(B);
1 2 1 2 2 3

2 件のコメント

L. Edwin M.
L. Edwin M. 2022 年 3 月 11 日
Perfect! Thanks a lot!
Voss
Voss 2022 年 3 月 11 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCell Arrays についてさらに検索

質問済み:

2022 年 3 月 11 日

コメント済み:

2022 年 3 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by