cell2mat error

조회 수: 4 (최근 30일)
Diogo Carvalho
Diogo Carvalho 2019년 4월 16일
댓글: Diogo Carvalho 2019년 4월 16일
I have the following cell array:
C =
4×1 cell array
{'1 1 3 2' }
{'2 3 5 2' }
{'3 4 5 3' }
{'4 1 4 3 '}
and wish to turn its contents into a matrix, but when I use cell2mat on it it outputs "Error using cat
Dimensions of arrays being concatenated are not consistent."
I've tried using str2double but it just outputs NaN.

채택된 답변

KSSV
KSSV 2019년 4월 16일
C = [{'1 1 3 2' }
{'2 3 5 2' }
{'3 4 5 3' }
{'4 1 4 3 '}] ;
C = cell2mat(cellfun(@str2num,C,'UniformOutput',false))
  댓글 수: 1
Diogo Carvalho
Diogo Carvalho 2019년 4월 16일
awesome, thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by