Cell array row deletion
5 次查看(过去 30 天)
显示 更早的评论
Hi! I have a cell array with a 10647x16 dimension. In the first column I have an identifying name for each row. I want to delete the rows that match the column names I have. I'll put a picture for better reference.
I want to delete the rows that match the 'filename' I write. I need to delete 40 rows.
1 个评论
豆 张
2022-2-18
I'm so sorry to bother you. I would like to include this data of yours in my research paper, if it is possible, could you please send me the complete table. I really need it!! Thank you so so much~~
PS:My email:zlwww142536@163.com
回答(2 个)
Fangjun Jiang
2021-1-19
c={'a',1,2;'b',3,4}
index=strcmp(c(:,1),'a')
c(index,:)=[]
3 个评论
Fangjun Jiang
2021-1-20
What do you mean 40 files? 40 filenames maybe?? You can remove multiple rows in one shot.
c={'a',1,2;'b',3,4;'c',1,2;'d',2,3;'e',5,6}
filenames={'b';'d'}
index=ismember(c(:,1),filenames);
c(index,:)=[]
Image Analyst
2021-1-19
Use ismember(). Something like...
fileNamePattern = 'MUSE20180113_171327_27000';
% Compare this character array to the list of them in column 1 of ca (the cell array)
% and find out which row contains it.
[~, row] = ismember({fileNamePattern}, ca(:, 1));
% Delete it
if ~isempty(row)
ca(row, :) = [];
end
Attach your cell array if that doesn't work.
2 个评论
Image Analyst
2021-1-20
Did you miss the last sentence in my answer? I'll check back tomorrow for it.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!