Extract two floating point numbers from a string
古いコメントを表示
This should be easy, but I have no experience with MATLAB regexp or pattern and can't adapt the other answers about extracting numbers from a mixed string.
I want to get the latitude and longitude as floating point numbers from a string that looks like this:
23.047°S 67.782°W
The numbers will have 1-3 characters before the decimal point. An "S" or a "W" will produce a negative number.
Suggestions welcome.
採用された回答
その他の回答 (1 件)
T = '23.047°S 67.782°W 9.876°N 5.432°E' ;
V = sscanf(regexprep(T,{'(\S+)°[SW]','(\S+)°[NE]'},{'-$1','+$1'}),'%f')
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!