Removing certain lines of text from a cell array
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a 53218x1 cell named N1. It is a cell consisting of the names of galaxies I have taken from a loaded ASCII catalog. I need to remove galaxies that have the first three letters starting with 'ESO'. There are 5,980 of these lines of code I have to remove. How would I do that? Would a 'for loop' work?
SIDE NOTE: these words all are 1x10 char in N1.
댓글 수: 0
채택된 답변
Titus Edelhofer
2015년 6월 12일
Hi,
that should be fairly straight forward:
% find the indices of ESO
idx = strncmp(N1, 'ESO', 3);
% and remove them:
N1(idx) = [];
Titus
댓글 수: 0
추가 답변 (1개)
Azzi Abdelmalek
2015년 6월 12일
v={'esoabcd';'abcgd';'ehdf';'esoez'}
out=v(cellfun(@isempty,regexp(v,'(?<=eso).+')))
댓글 수: 2
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!