How do I make this mask statement more concise?

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?

 채택된 답변

Image Analyst
Image Analyst 2017년 12월 4일

0 개 추천

Here's one way:
message = 'abc0123456def7890ghi'
message(message >= '0' & message <= '9') = []

추가 답변 (1개)

Walter Roberson
Walter Roberson 2017년 12월 4일

1 개 추천

message = message(~ismember(message, '0123456789'))

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

질문:

2017년 12월 4일

답변:

2017년 12월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by