how to omit the the dot and numbers
2 次查看(过去 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
0 个评论
采纳的回答
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');
0 个评论
更多回答(1 个)
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,'.'))=[];
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!