delete matrix in cell
    조회 수: 13 (최근 30일)
  
       이전 댓글 표시
    
let's say: I have 2 cell: cell_A  and  cell_B 
cell_A=1x5 cell={[1 1 1]  [1 2 3;3 2 1]  [4 5 6;7 8 9;1 1 1]  [2 2 2;3 3 3]  [9 9 9]};
cell_B=1x3 cell={[1 1 1]  [1 2 3;3 2 1]   [9 9 9]};
How can i delete same matrix in cell_A and cell_B. The result is:
cell_result=1x2 cell={ [4 5 6;7 8 9;1 1 1]  [2 2 2;3 3 3]};
댓글 수: 0
채택된 답변
  KSSV
      
      
 2019년 5월 14일
        cell_A={[1 1 1]  [1 2 3;3 2 1]  [4 5 6;7 8 9;1 1 1]  [2 2 2;3 3 3]  [9 9 9]};
cell_B={[1 1 1]  [1 2 3;3 2 1]   [9 9 9]};
m = length(cell_A) ; 
n = length(cell_B) ; 
iwant = cell_A ; 
for i = 1:m
    for j = 1:n
       if isequal(cell_A{i},cell_B{j})            
           iwant{i} = [] ;
       end
    end
end
% Remove empty cells
idx = cellfun(@isempty,iwant) ;
iwant(idx) = [] ;
celldisp(iwant)
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

