Dynamic Loop with for

1 vue (au cours des 30 derniers jours)
Dzevat
Dzevat le 9 Août 2018
Rouvert : Walter Roberson le 22 Déc 2018
Dynamic Loop
  1 commentaire
Stephen23
Stephen23 le 9 Août 2018
What is a "dynamic loop"? Please show us your code so we have some idea of what you are doing.

Connectez-vous pour commenter.

Réponse acceptée

KSSV
KSSV le 9 Août 2018
Modifié(e) : KSSV le 9 Août 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 commentaire
KSSV
KSSV le 9 Août 2018
The code should work for any N...edited the code with present N..check.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by