Removing certain lines of text from a cell array
2 次查看(过去 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!