MATLAB Answers

0

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

  0 Comments

Sign in to comment.

1 Answer

Answer by Stephen Cobeldick on 10 Nov 2015
Edited by Stephen Cobeldick on 10 Nov 2015
 Accepted Answer

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 Comments

Sign in to comment.