How to remove similar element in cell?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
2018년 8월 3일
Why there are four [195,249] in your expected result? Aren't you trying to remove all duplicate numbers?
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!