Clean solution to shrink matrices
조회 수: 10 (최근 30일)
이전 댓글 표시
I have pre-allocated a large Matrix X = (80000,8). for e.g zeros(80000,8); This I did for speed. After several operations I only filled say 1000 rows of the matrix and remaining are all zeros as I pre-allocated all elements to be zero to start with. Now I would like the shrink the matrix to smaller one by eliminating all the trivial rows in the end. What is the cleanest way of doing them?
댓글 수: 0
채택된 답변
추가 답변 (1개)
John D'Errico
2017년 5월 9일
As long as you know how many rows are filled (call it n, here n is 1000), then just do
X = X(1:n,:);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!