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

11 次查看(过去 30 天)
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 个)

类别

Help CenterFile Exchange 中查找有关 Operators and Elementary Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by