How can I delete a certain number of rows in a vector?
1 次查看(过去 30 天)
显示 更早的评论
Dear all, I have a 2505*1 vector with only 1 and 0. The number 1 occurs 178 times. I want to delete the first 158 rows with an 1 and the last 20 rows and the rows with 0 should stay! How can I do that? Thank you in advance!
0 个评论
采纳的回答
Image Analyst
2013-4-2
rowsWithOnes = find(vector == 1)
vector(rowsWithOnes(1:158)) = []; % Delete first 158
vector(rowsWithOnes(end-19:end)) = []; % Delete last 20
0 个评论
更多回答(1 个)
Azzi Abdelmalek
2013-4-2
编辑:Azzi Abdelmalek
2013-4-2
idx=find(A)
idx1=[idx(1:158) idx(end-19:end)]
A(idx1)=[];
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!