I have got a cell(198x1) and i try to convert the cell in to a matrix but cell2mat doesen't work.

답변 (2개)

Voss
Voss 2024년 2월 8일

0 개 추천

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}
C = 2×1 cell array
{[1 2]} {[ 3]}
cell2mat(C)
Error using cat
Dimensions of arrays being concatenated are not consistent.

Error in cell2mat (line 83)
m{n} = cat(1,c{:,n});
Is that the error you got?

댓글 수: 2

Carolina Giulia
Carolina Giulia 2024년 2월 12일
Yes the error is:
Error using cat
Dimensions of arrays being concatenated are not consistent.
Error in cell2mat (line 83)
m{n} = cat(1,c{:,n});
And my cell is numeric, a single line with 198 numbers
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
Walter Roberson 2024년 2월 8일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

질문:

2024년 2월 8일

댓글:

2024년 2월 12일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by