Trying to find the odd and even number from 3:200 using equation mentioned below

1 Ansicht (letzte 30 Tage)
n = 3:1:200;
B = rem(n,2);
if B == 0
x = (n-4/2) + 0.5;
else
x = (n-3)/2 + 1 ;
end

Akzeptierte Antwort

Matt J
Matt J am 28 Nov. 2022
Bearbeitet: Matt J am 28 Nov. 2022
n = 3:200;
even=~rem(n,2);
x = (n-3)/2 + 1 ;
x(even)=(n-4)/2+0.5;

Weitere Antworten (0)

Kategorien

Mehr zu Modeling finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by