How to separate numbers and text from a string

7 vues (au cours des 30 derniers jours)
Venkatapathi
Venkatapathi le 28 Jan 2014
Commenté : Nader Virk le 25 Fév 2022
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

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 28 Jan 2014
Modifié(e) : Azzi Abdelmalek le 28 Jan 2014
s = 'x 5.67 y 7.789'
out=str2double(regexp(s,'[\d.]+','match'))
  4 commentaires
Bhupinder Saini
Bhupinder Saini le 5 Sep 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 le 25 Fév 2022
For string s, I appreciate if someone could help how to get only the chracters? Thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by