Cycle For how can i??

3 visualizzazioni (ultimi 30 giorni)
Jah-lahfui il 15 Gen 2015
Commentato: Jah-lahfui il 16 Gen 2015
Hello guys i have a matrix W(418*413) i need to do a "for cycle" that goes from 2:417 and that goes from 2:412 but instead of writing down the final number i want write "end-1" but when i write end it assumes that im ending the cycle of course, how can i write the right way so it can identify that it goes from 2 line till end-1.
P.e. for nx=2:412 but instead of writing 412 i want it "end-1"
for ny=2:417 the same here.
end end

Risposta accettata

Ilham Hardy
Ilham Hardy il 15 Gen 2015
Modificato: Ilham Hardy il 16 Gen 2015
If i fully understand the question, below is the "cycle for loop" that you want,
for idrow = 2:size(W,1)-1
for idcol = 2:size(W,2)-1
do stuff
  2 Commenti
Jah-lahfui il 16 Gen 2015
Just could you tell me whats the point of making size(W,1) and size(W,2). The function size(W,dim) what means dim?

Accedi per commentare.

Più risposte (1)

Iain il 15 Gen 2015
for i = 2:numel(x)
do stuff
  2 Commenti
Stephen23 il 16 Gen 2015
Iain is right: numel is the way to get the result that you want.

Accedi per commentare.


Scopri di più su Multidimensional Arrays in Help Center e File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by