cell2mat not working
조회 수: 21 (최근 30일)
이전 댓글 표시
I have got a cell(198x1) and i try to convert the cell in to a matrix but cell2mat doesen't work.
댓글 수: 0
답변 (2개)
Voss
2024년 2월 8일
If the contents of the cells cannot be concatenated into a matrix, then you'll get an error telling you so.
For example:
C = {[1 2]; 3}
cell2mat(C)
Is that the error you got?
댓글 수: 2
Walter Roberson
2024년 2월 12일
Please show the output of
temp = cellfun(@size, YourCell(:), 'uniform', 0);
maxlen = max(cellfun(@length, temp));
sizes = cell2mat(cellfun(@(V) [V ones(1,maxlen - length(V))], temp, 'uniform', 0));
unique_sizes = unique(sizes, 'row')
Walter Roberson
2024년 2월 8일
If the cell contents are not numeric, then cell2mat() might refuse. In such a case, you can try
As_Matrix = cat(1, TheCell{:});
if you want to end up with a 198 x something array.
댓글 수: 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!