how to omit the the dot and numbers

2 visualizaciones (últimos 30 días)
Jwana
Jwana el 21 de Nov. de 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

Respuesta aceptada

Jan
Jan el 21 de Nov. de 2012
Editada: Jan el 21 de Nov. de 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');

Más respuestas (1)

Richard
Richard el 21 de Nov. de 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,'.'))=[];

Categorías

Más información sobre Cell Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by