필터 지우기
필터 지우기

Deleting line containing symbol.

조회 수: 4 (최근 30일)
ZK
ZK 2013년 2월 4일
Hi can You help me finish this command:
E(any(regexp(E, 'A|' , 'match' );,2),:) = [];
Deleting line in variable E(readed by textscan), containing A|.
Thank You.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 4일
편집: Azzi Abdelmalek 2013년 2월 4일
E={'| 00:00 | A| | A| A| A|'
'| 00:15 | 1.21 | | 1.34 | 1.42 | 1.34 |'
'| 00:30 | 1.42 | | 1.76 | 1.34 | 1.45 |'
'| 00:45 | 1.23 | | 1.34 | 1.67 | 1.23 |'}
out=cellfun(@(x) strrep(x,'A|',''),E,'un',0)
out=cellfun(@(x) strrep(x,'|',''),out,'un',0)
  댓글 수: 6
Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 4일
Ok
E={'| 00:00 | A| | A| A| A|'
'| 00:15 | 1.21 | | 1.34 | 1.42 | 1.34 |'
'| 00:30 | 1.42 | | 1.76 | 1.34 | 1.45 |'
'| 00:45 | 1.23 | | 1.34 | 1.67 | 1.23 |'}
idx=find(cell2mat(cellfun(@(x) ~any(strfind(x,'A|')),E,'un',0)))
out=E(idx)
ZK
ZK 2013년 2월 4일
Working great. Thank You for Your time, and great answer of course.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 4일
E='assA|stA|'
idx=regexp(E,'A|')
E(idx+1)=[]
  댓글 수: 4
Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 4일
%or
E={'assA|stA|';'azekaA|assaA|'}
for k=1:numel(E)
a=E{k}
idx=regexp(a,'A|')
a(idx+1)=[]
E{k}=a
end
ZK
ZK 2013년 2월 4일
편집: Azzi Abdelmalek 2013년 2월 4일
Yes of course, sorry for that.
Example:
E<1x1 cell>
<4x1 cell>
| 00:00 | A| | A| A| A|
| 00:15 | 1.21 | | 1.34 | 1.42 | 1.34 |
| 00:30 | 1.42 | | 1.76 | 1.34 | 1.45 |
| 00:45 | 1.23 | | 1.34 | 1.67 | 1.23 |

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by