i have 50x5 matrix, i want to delete some of the rows but unfortunately the rows which i want to delete are not at equal interval,so i need help
1 次查看(过去 30 天)
显示 更早的评论
i want delete the rows which contains first two rows and last 3 rows of every constant value of 1st column 3 zeros.
0 个评论
回答(1 个)
the cyclist
2016-6-7
编辑:the cyclist
2016-6-7
If you have loaded the data into a matrix "M", then you can do this with
deleteRowIndex = ismember(M(:,end-2:end),[0 0 0],'rows');
M(deleteRowIndex,:) = [];
This takes advantage of the fact that the rows you want to delete are of the form
[a b 0 0 0]
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!