matrix loop with changing rows and columns
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Dear all,
I have written a loop but I want to tell matlab that it should avoid always a range of certain 56 columns, and add the same time switch to the next rows. I dont know why, but the second part of the sum won't work.
j=0;
em_emb= ones([44,1]);
while j<56;
f_rs_i =sum(Z(1+j:56+j,1:2464-1+j:56+j),1);
j = j+56;
em_emb(j)= f_rs_i;
end
Thanks in advance
0 comentarios
Respuestas (1)
Image Analyst
el 10 de En. de 2021
What is Z? What is the range of columns you want to skip? Why not just do 2 nested for loops?
[rows, columns] = size(Z)
for row = 1 : rows
for col = 1 : columns
if col > col1 || col <= col2
% Don't process these columns.
continue;
end
% else this column is okay to process so do something.
end
end
3 comentarios
Image Analyst
el 10 de En. de 2021
Then just start at column 57:
for row = 1 : rows
for col = 57 : columns
% Do stuff
end
end
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!