Extract numeric value from a cell in a table.
119 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jorge Alberto Fuentes Casillas
le 16 Déc 2016
Commenté : Elton Martinez
le 9 Juin 2023
Hello to all!
I want to extract the numeric values of a mixed data that I have in a cell of an array. This is what I have done:
T = readtable('file.dat','Format','%s'); %Which creates a table with 1 column and 525606 rows.
latitude = T{1,1} %which creates an array with the next output:
latitude =
'12.967 [deg N]'
only one char value.
What I want to do now is to get only the numerical value from that array, I've tried char2string and sscanf but it only prompts errors and no conversion. Please help :) I know that it seems to be a simple procedure but I'm stuck here.
Thanks in advance!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/159032/image.png)
Réponse acceptée
Plus de réponses (1)
José-Luis
le 16 Déc 2016
C = strsplit(T{1,1})
your_val = str2num(C{1});
7 commentaires
Elton Martinez
le 9 Juin 2023
The following is missing something T{1,1}{1} should work, for future reference
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!