How to separate numbers and text from a string

39 次查看(过去 30 天)
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