matrix loop with changing rows and columns

3 visualizaciones (últimos 30 días)
Victoria Pake
Victoria Pake el 10 de En. de 2021
Comentada: Image Analyst el 10 de En. de 2021
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

Respuestas (1)

Image Analyst
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
Victoria Pake
Victoria Pake el 10 de En. de 2021
Z is a matrix 2464x2464, i want to skip always 56 columns
Image Analyst
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

Iniciar sesión para comentar.

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