Extract numeric value from a cell in a table.
显示 更早的评论
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!

采纳的回答
更多回答(1 个)
José-Luis
2016-12-16
C = strsplit(T{1,1})
your_val = str2num(C{1});
7 个评论
Try replacing
T{1,1}
by
[T{:}]
Jorge Alberto Fuentes Casillas
2016-12-16
编辑:Jorge Alberto Fuentes Casillas
2016-12-16
José-Luis
2016-12-16
You'll have to show what you actually have in T
Jorge Alberto Fuentes Casillas
2016-12-16
José-Luis
2016-12-16
And what does T{1} return?
Jorge Alberto Fuentes Casillas
2016-12-16
Elton Martinez
2023-6-9
The following is missing something T{1,1}{1} should work, for future reference
类别
在 帮助中心 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
