필터 지우기
필터 지우기

how to omit the the dot and numbers

조회 수: 1 (최근 30일)
Jwana
Jwana 2012년 11월 21일
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