I want to only run my loop till 22 but it shoud take odd numbers for x_random and even for y_random

1 Ansicht (letzte 30 Tage)
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

Akzeptierte Antwort

KSSV
KSSV am 4 Okt. 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

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by