I want to only run my loop till 22 but it shoud take odd numbers for x_random and even for y_random
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Bushra Atta Khakwani khakwani
le 4 Oct 2022
Réponse apportée : KSSV
le 4 Oct 2022
while i < 22
if mod(i,2)==0
P(2,i) = y_random(i); %y coordinate
else
P(1,i) = x_random(i); %x coordinate
end
end
0 commentaires
Réponse acceptée
KSSV
le 4 Oct 2022
for i=1:22
if mod(i,2)==0
P(2,i) = y_random(i); %y coordinate
else
P(1,i) = x_random(i); %x coordinate
end
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!