How to convert a cell array of cell arrays to matrix ?
    조회 수: 7 (최근 30일)
  
       이전 댓글 표시
    
I need to convert a cell array of cell arrays to matrix. I tried to use cell2mat() , but I am getting an error message.
C={{1 3 4};{1 3 3}}
C =
    {1x3 cell}
    {1x3 cell}
 cell2mat(C)
Error using cell2mat (line 53)
Cannot support cell arrays containing cell arrays or objects.
댓글 수: 0
채택된 답변
  Azzi Abdelmalek
      
      
 2015년 7월 27일
        
      편집: Azzi Abdelmalek
      
      
 2015년 7월 27일
  
      C={{1 3 4};{1 3 3}}
out=cell2mat(cellfun(@(x) cell2mat(x),C,'un',0))
댓글 수: 3
  Azzi Abdelmalek
      
      
 2015년 7월 27일
				This has nothing to do with the fact that tour cell array is bigger. Your example is not representative of your data. Please give more details about your cells.
  Azzi Abdelmalek
      
      
 2015년 7월 27일
				Maybe your cell array looks like
C={{1 3 4};{1 3 3};[1 2 3]}
The third element is not a cell array
추가 답변 (1개)
  Abhinuv Pitale
      
 2018년 9월 12일
        With different type of objects in the array, you cant use the lambda as suggested above!
댓글 수: 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!


