How to separate numbers and text from a string

조회 수: 7 (최근 30일)
Venkatapathi
Venkatapathi 2014년 1월 28일
댓글: Nader Virk 2022년 2월 25일
Hello,
i have string variable s = 'x 5.67 y 7.789';
i would like to read only numbers from the string.
requesting you to help me, how to separate numbers and text from the string.
Thanks & Regards Venkatapathi.P

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 1월 28일
편집: Azzi Abdelmalek 2014년 1월 28일
s = 'x 5.67 y 7.789'
out=str2double(regexp(s,'[\d.]+','match'))
  댓글 수: 4
Bhupinder Saini
Bhupinder Saini 2018년 9월 5일
How do you alter this to return the characters only in the string?
i.e. x.h y g j
Nader Virk
Nader Virk 2022년 2월 25일
For string s, I appreciate if someone could help how to get only the chracters? Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by