cell2mat error due to element size?

1 visualización (últimos 30 días)
Aldrich To
Aldrich To el 16 de Nov. de 2015
Comentada: Mohammad Abouali el 19 de Nov. de 2015
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!

Respuesta aceptada

Mohammad Abouali
Mohammad Abouali el 16 de Nov. de 2015
Editada: Mohammad Abouali el 16 de Nov. de 2015
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 comentarios
Aldrich To
Aldrich To el 19 de Nov. de 2015
Thanks Mohammad!
Mohammad Abouali
Mohammad Abouali el 19 de Nov. de 2015
You are welcome.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by