How do I make this mask statement more concise?

1 visualizzazione (ultimi 30 giorni)
I have a problem where I need to remove all numerical characters from a string. I currently have it like this:
message = message(message != '0')
message = message(message != '1')
and so on
I want to condense these into a single statement, but I'm having trouble figuring out how to. How would I go about making this more concise?

Risposta accettata

Image Analyst
Image Analyst il 4 Dic 2017
Here's one way:
message = 'abc0123456def7890ghi'
message(message >= '0' & message <= '9') = []

Più risposte (1)

Walter Roberson
Walter Roberson il 4 Dic 2017
message = message(~ismember(message, '0123456789'))

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