remove the number at the end of the string in cell array

I have a cell array a = { 'Gain' ; 'Gain1' ; 'Delay' ; 'Delay1'}
I need to remove the number at the end of the string. How can i do this?
answer should be a = { 'Gain' ; 'Gain' ; 'Delay' ; 'Delay'} ;
Thanks a lot

 채택된 답변

Stephen23
Stephen23 2015년 11월 10일
편집: Stephen23 2015년 11월 10일
You can use regexprep for this:
>> a = { 'Gain' ; 'Gain1' ; 'Delay' ; 'Delay1'};
>> b = regexprep(a,'\d+$','')
>> b{:}
ans = Gain
ans = Gain
ans = Delay
ans = Delay

추가 답변 (0개)

카테고리

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

질문:

2015년 11월 10일

편집:

2015년 11월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by