Extract numeric value from a cell in a table.
조회 수: 146 (최근 30일)
이전 댓글 표시
Jorge Alberto Fuentes Casillas
2016년 12월 16일
댓글: Elton Martinez
2023년 6월 9일
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
Elton Martinez
2023년 6월 9일
The following is missing something T{1,1}{1} should work, for future reference
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!