How to convert multi sized cell array into an MxN matrix
조회 수: 4 (최근 30일)
이전 댓글 표시
I have a cell array of 1x257 in which each cell array column contains different sized Mx1 array as shown in the screenshot. ![Cell_array.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/209805/Cell_array.jpeg)
![Cell_array.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/209805/Cell_array.jpeg)
As you can see, each column in this cell array has different number or rows in it. I need to convert this cell array named Voltage into a matrix with each column contains all the numerical data that is present in the correspoding cell array column.
That means, the first cell array has 143 rows. So the column 1 of my new matrix has 143 rows. Similarly column 2 contains 44 rows etc. upto 257 columns. Is it even possible to form a table of different rows ?
Advance gratitude for any help.
댓글 수: 0
채택된 답변
Jan
2019년 3월 22일
편집: Jan
2019년 3월 25일
Matrices have te same number of elements in all columns and rows, repsectively. This is the definition of a matrix. So you cannot store vectors of different lengths in a matrix.
You can pad the vectors with NaNs, if this is sufficient for your problem. But storing a collection of vectors of different size in a cell array seems to be clear, clean and efficient.
추가 답변 (0개)
참고 항목
카테고리
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!