필터 지우기
필터 지우기

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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by