Dynamic Loop with for

1 visualizzazione (ultimi 30 giorni)
Dzevat
Dzevat il 9 Ago 2018
Riaperto: Walter Roberson il 22 Dic 2018
Dynamic Loop
  1 Commento
Stephen23
Stephen23 il 9 Ago 2018
What is a "dynamic loop"? Please show us your code so we have some idea of what you are doing.

Accedi per commentare.

Risposta accettata

KSSV
KSSV il 9 Ago 2018
Modificato: KSSV il 9 Ago 2018
N = [6 44 ; 170 179 ; 198 203] ;
iwant = cell(size(N,1),1) ;
for i = 1:size(N,1)
for j = N(i,1):N(i,2)
iwant{i} = [iwant{i} j] ; % just demo to show the variables after loop
end
end
iwant{1}
iwant{2}
iwant{3}
  1 Commento
KSSV
KSSV il 9 Ago 2018
The code should work for any N...edited the code with present N..check.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Creating, Deleting, and Querying Graphics Objects in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

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

Start Hunting!

Translated by