How to select rows in a matrix with a for loop?

2 visualizaciones (últimos 30 días)
Shayma Al Ali
Shayma Al Ali el 13 de Dic. de 2020
Respondida: Ameer Hamza el 13 de Dic. de 2020
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

Respuestas (1)

Ameer Hamza
Ameer Hamza el 13 de Dic. de 2020
Following code is more efficient and outputs what you want
density = densityt(1:817, :)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by