How to select rows in a matrix with a for loop?
조회 수: 3 (최근 30일)
이전 댓글 표시
I have a 3061x107 matrix. I want to reduce it to a 817x107 matrix. My current code currently saves what I want as a new matrix into a very large column so its 87000x1.
My current code:
density=[];
for i=1:length(densityt)
dcol=densityt(:,i);
dcol=dcol(1:817,:);
density=[density;dcol];
end
댓글 수: 0
답변 (1개)
Ameer Hamza
2020년 12월 13일
Following code is more efficient and outputs what you want
density = densityt(1:817, :)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!