Effacer les filtres
Effacer les filtres

how to omit the the dot and numbers

2 vues (au cours des 30 derniers jours)
Jwana
Jwana le 21 Nov 2012
Hi,,
I have this command :
PC_DI = a0.c1.c3.d12
tt=regexp(PC_DI, '.', 'match')
tt =
'a' '0' '.' 'c' '1' '.' 'c' '3' '.' 'd' '1' '2'
how can I cancel the numbers and dots, that the result should be as follows:
tt =
'a' 'c' 'c' 'd'
Thanks

Réponse acceptée

Jan
Jan le 21 Nov 2012
Modifié(e) : Jan le 21 Nov 2012
If "PC_DI = a0.c1.c3.d12" should mean this:
PC_DI = 'a0.c1.c3.d12'
I suggest to omit the regexp and use:
tt = PC_DI(isletter(PC_DI));
Alternatively, if you are looking for lowercase letters only:
tt = PC_DI(PC_DI >= 'a' & PC_DI <= 'z');
If you need the output to be a cellstring:
tt = cellstr(tt');

Plus de réponses (1)

Richard
Richard le 21 Nov 2012
Not sure yet about cancelling the numbers, but you could omit the dots as follows:
tt = {'a','0','.','c','1','.','c','3','.','d','1','2'};
tt(strcmp(tt,'.'))=[];

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by