cell2mat error

4 visualizaciones (últimos 30 días)
Diogo Carvalho
Diogo Carvalho el 16 de Abr. de 2019
Comentada: Diogo Carvalho el 16 de Abr. de 2019
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.

Respuesta aceptada

KSSV
KSSV el 16 de Abr. de 2019
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 comentario
Diogo Carvalho
Diogo Carvalho el 16 de Abr. de 2019
awesome, thanks.

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.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by