Dynamic Loop with for

1 Ansicht (letzte 30 Tage)
Dzevat
Dzevat am 9 Aug. 2018
Erneut geöffnet: Walter Roberson am 22 Dez. 2018
Dynamic Loop
  1 Kommentar
Stephen23
Stephen23 am 9 Aug. 2018
What is a "dynamic loop"? Please show us your code so we have some idea of what you are doing.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

KSSV
KSSV am 9 Aug. 2018
Bearbeitet: KSSV am 9 Aug. 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 Kommentar
KSSV
KSSV am 9 Aug. 2018
The code should work for any N...edited the code with present N..check.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by