How to convert cell to double array?
617 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Gil Cheah
el 19 de Jul. de 2017
Respondida: Philipp Prestel
el 24 de Jun. de 2023
My data is with size of 2050x1 and its class label as 'cell', how do convert it into double so that i can plot the graph? thanks for the help in advance
0 comentarios
Respuesta aceptada
Geoff Hayes
el 19 de Jul. de 2017
Gil - is each element of your cell array a numeric scalar or numeric array? See cell2mat which provides some examples on how you might do this conversion.
0 comentarios
Más respuestas (2)
Damdae
el 27 de Jul. de 2019
Try str2double:
cell2mat({'01'}) = '01' (double)
str2double({'01'}) = 1 (char)
1 comentario
Giuseppe Degan Di Dieco
el 29 de Nov. de 2021
Thanks Damdae, very useful tip to convert
cell array, containg numbers, to double.
Best.
Philipp Prestel
el 24 de Jun. de 2023
The absolute easiest way I know is comma seperated list assignment, which looks like this;
a = [{25}; {31}; {24}; {5}; {23}; {64}; {12}; {53}; {22}];
b = [a{:}]'
I don't know whrether it is any good, but it works if the values of all cells are of the same type. just keep in mind that it will transpose a columnvector to a rowvector.
0 comentarios
Ver también
Categorías
Más información sobre Construct and Work with Object Arrays 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!