Identify a number in a string
22 ビュー (過去 30 日間)
古いコメントを表示
Omphemetse Moeng
2020 年 10 月 11 日
コメント済み: Omphemetse Moeng
2020 年 10 月 11 日
Hi all, I would like to know how to identify and extract a number or digit from a string or text, so if I have Ans = ['2.66 meters in the front of the mirror']; I would only like to identify and extract the double, this should be a general thing and not only specific to the 2.66. Please help
0 件のコメント
採用された回答
その他の回答 (1 件)
Ameer Hamza
2020 年 10 月 11 日
編集済み: Ameer Hamza
2020 年 10 月 11 日
Try sscanf()
str = '2.66 meters in the front of the mirror';
nums = sscanf(str, '%f');
Result
>> nums
nums =
2.6600
参考
カテゴリ
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!