How to convert a cell array (nx1) with different size of elements in each cell to a matrix?
    8 ビュー (過去 30 日間)
  
       古いコメントを表示
    
 Suppose I have a nx1 cell as follows:
X = [0,160,208]
[272,132]
[1272,133]
[22724,310]
[27516,312]
[30424,374,687]
[32262,437]
[36288,299,574,690]
[47884,637]
[53542,425]
[54494,633]
[58420,77]
[62800,461]
[72252,239]
[78429,46]
I want something like:
newX = [ 0    160   208
        272   132
       1272   133
       22724  310
       27516  312
      30424   374   687
      32262   437 
      36288   299   574   690
      47884   637
      53542   425
      54494   633
      58420   77
      62800   461
      72252   239
      78429   46 ]
That is each element of the cell X should be stored in new column of the newX.
(I have tried something with pre-defining the new array but I do not want any NaN or Zeros after I pre-define it. )
Your help will be greatly appreciated as I am very new to Matlab.
Thank you
1 件のコメント
  Matt Fig
      
      
 2012 年 10 月 4 日
				So if you do not want a nan or a zero in the non-used spots, what do you want there? MATLAB will not allow an empty element of a numeric array. If an array is numeric, this means that each element of the array is numeric...
回答 (1 件)
  Walter Roberson
      
      
 2012 年 10 月 3 日
        That is not possible in MATLAB. MATLAB does not support "ragged arrays". If you want an array, then the unused locations must be populated with something
1 件のコメント
  Walter Roberson
      
      
 2012 年 10 月 4 日
				Note that if your goal is just to display it with different numbers of elements per line, then that is feasible.
参考
カテゴリ
				Help Center および File Exchange で Data Type Conversion についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


