How do I convert a column to numeric?
46 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
jakobjakob
el 6 de Jun. de 2018
Comentada: jakobjakob
el 6 de Jun. de 2018
See the image
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/191048/image.png)
I want to count with the 1st column, but I always get the message "Undefined operator" - "for input arguments or type 'cell'." What can I do about it? I think the column is not numeric, but I am not sure. Who can help me?
Respuesta aceptada
Stephen23
el 6 de Jun. de 2018
Editada: Stephen23
el 6 de Jun. de 2018
Where C is your cell array:
V = str2double(C(:,1))
This assumes that there is no header, and that each cell of the first column contains one number stored as a char (using a dot, not comma).
9 comentarios
Stephen23
el 6 de Jun. de 2018
Editada: Stephen23
el 6 de Jun. de 2018
- {} curly braces access the data inside the cells.
- () parentheses access the cells themselves.
Just think of cell arrays like boxes: do you want to pick up the box (the cell, ()), or whatever that is inside the box (the data, {}). Sometimes you want to pick up the box, and sometimes you want to get out whatever is inside... each of these can be useful.
Therefore to access the contents of one cell you just need to use curly braces:
alldata{1,1} - 10
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Type Identification 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!