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

조회 수: 1 (최근 30일)
n = 3:1:200;
B = rem(n,2);
if B == 0
x = (n-4/2) + 0.5;
else
x = (n-3)/2 + 1 ;
end

채택된 답변

Matt J
Matt J 2022년 11월 28일
편집: Matt J 2022년 11월 28일
n = 3:200;
even=~rem(n,2);
x = (n-3)/2 + 1 ;
x(even)=(n-4)/2+0.5;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by