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!