How to convert cell to matrix
    조회 수: 6 (최근 30일)
  
       이전 댓글 표시
    
I have a cell which is given by A= 1x13cell. I want to extract the contents of the cell into the form of a matrix of size (13 x number of points each cell containd) is this possible? The number of points in each cell varies. Can you help me with this?
댓글 수: 2
  Jos (10584)
      
      
 2013년 7월 16일
				I suggest you give a small example. For instance, if
C = {[1 2],[11 12 13]} % a cell array
how would you like the final matrix M to look like? Something like
1   2  NaN
11  12   13
?
답변 (3개)
  David (degtusmc)
      
 2013년 7월 16일
        
      편집: David (degtusmc)
      
 2013년 7월 16일
  
      Look up cell2mat. The link for the documentation is below. I hope this helps
댓글 수: 3
  Evan
      
 2013년 7월 16일
				This will only work for cells arrays containing matrices of constant size in each array.
  Jos (10584)
      
      
 2013년 7월 17일
        
      편집: Jos (10584)
      
      
 2013년 7월 17일
  
      Here is a suggestion
C = {[1 2 ;3 4],[11 12 13].',100:106} % a cell array
% make sure all elements are column vectors 
C2 = cellfun(@(x) reshape(x,[],1), C,'un',0) ; 
M = padcat(C2{:})
참고 항목
카테고리
				Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





