フィルターのクリア

How to remove similar element in cell?

1 回表示 (過去 30 日間)
laith Farhan
laith Farhan 2018 年 8 月 3 日
コメント済み: laith Farhan 2018 年 8 月 4 日
Dear Sir,
Is that possible to remove the similar element in each cell based on previous cell. for example:
z={[],[],282,[195,249,282],[195,249,282],[195,249,282],[195,249,282],[103,195,249,282],[103,195,249,282] [104,1,50,103,195,249,282]}
My I get the expected results below:? results = {[], [], 282, [195,249], [195,249], [195,249], [195,249], [103],[], [104,1,50],}
Thanks in advance and sorry for bothering you.
  2 件のコメント
Albert Fan
Albert Fan 2018 年 8 月 3 日
Why there are four [195,249] in your expected result? Aren't you trying to remove all duplicate numbers?
laith Farhan
laith Farhan 2018 年 8 月 3 日
Dear Albert, Yeah that true. I did mistake. therefore the expected results is : results = {[], [], 282, [195,249], [], [], [], [103],[], [104,1,50],}

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

採用された回答

Fangjun Jiang
Fangjun Jiang 2018 年 8 月 3 日
編集済み: Fangjun Jiang 2018 年 8 月 3 日
setdiff(), going through a loop
results=z;
for k=2:length(z)
results{k}=setdiff(z{k},z{k-1});
end
celldisp(results);
  3 件のコメント
Fangjun Jiang
Fangjun Jiang 2018 年 8 月 3 日
See updates with the code.
laith Farhan
laith Farhan 2018 年 8 月 4 日
Thanks Fangjun, that really amazing. it works

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by