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

13 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Stephen23
Stephen23 il 10 Nov 2015
Modificato: Stephen23 il 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

Più risposte (0)

Categorie

Scopri di più su Operators and Elementary Operations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by