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

17 views (last 30 days)
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

Accepted Answer

Stephen23
Stephen23 on 10 Nov 2015
Edited: Stephen23 on 10 Nov 2015
You can use regexprep for this:
>> a = { 'Gain' ; 'Gain1' ; 'Delay' ; 'Delay1'};
>> b = regexprep(a,'\d+$','')
>> b{:}
ans = Gain
ans = Gain
ans = Delay
ans = Delay

More Answers (0)

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!