Identify a number in a string
조회 수: 24 (최근 30일)
이전 댓글 표시
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!