cell2mat error due to element size?

조회 수: 2 (최근 30일)
Aldrich To
Aldrich To 2015년 11월 16일
댓글: Mohammad Abouali 2015년 11월 19일
Hi everyone.
I am getting the following error when I try to convert the cell array to a double.
C =
'104'
'98'
'98'
'98'
'94'
'94'
'100'
'100'
loadrange = str2num(cell2mat(C))
Error using cat
Dimensions of matrices being concatenated are not consistent.
Error in cell2mat (line 83)
m{n} = cat(1,c{:,n});
I believe the error is due to the number of elements not being the same size. Is there a way around this?
Thanks!

채택된 답변

Mohammad Abouali
Mohammad Abouali 2015년 11월 16일
편집: Mohammad Abouali 2015년 11월 16일
Use str2double() instead.
C={'104',
'98',
'98',
'98',
'94',
'94',
'100',
'100'};
loadrange = str2double(C)
loadrange =
104
98
98
98
94
94
100
100
  댓글 수: 2
Aldrich To
Aldrich To 2015년 11월 19일
Thanks Mohammad!
Mohammad Abouali
Mohammad Abouali 2015년 11월 19일
You are welcome.

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

추가 답변 (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