How to separate numbers and text from a string

7 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 28 Gen 2014
Modificato: Azzi Abdelmalek il 28 Gen 2014
s = 'x 5.67 y 7.789'
out=str2double(regexp(s,'[\d.]+','match'))
  4 Commenti
Bhupinder Saini
Bhupinder Saini il 5 Set 2018
How do you alter this to return the characters only in the string?
i.e. x.h y g j
Nader Virk
Nader Virk il 25 Feb 2022
For string s, I appreciate if someone could help how to get only the chracters? Thanks!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by