how to omit the the dot and numbers

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

采纳的回答

Jan
Jan 2012-11-21
编辑:Jan 2012-11-21
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');

更多回答(1 个)

Richard
Richard 2012-11-21
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,'.'))=[];

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by