deleting rows from matrix and saving as a new matrix
3 次查看(过去 30 天)
显示 更早的评论
Hello,
If I have a matrix 20 x 20, and I want to delete row 2 and 7,
I would use something like
MTX_1([2,7],:) = []
is there a way to save this new matrix as a separate array (such as MTX_2), while preserving the original MTX_1?
Thank you.
0 个评论
回答(1 个)
Star Strider
2018-11-28
Probably the easiest way:
MTX_2 = MTX_1(setdiff(1:size(MTX_1,1),[2,7]),:)
This creates ‘MTX_2’ while leaving ‘MTX_1’ unchanged.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!