using testtype to check odd or even numbers
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
In my code I try to use an 'if' operator to check whether a number is odd or even, so the code knows whether to proceed. So something like this:
if testtype(j, Type::Odd) = TRUE
statements
end
But that just gives the error:
Unexpected MATLAB operator.
1 Kommentar
Akzeptierte Antwort
Andrei Bobrov
am 28 Jun. 2013
Bearbeitet: Andrei Bobrov
am 28 Jun. 2013
if rem(jj,2) == 1 % odd
statements
elseif rem(jj,2) == 0 % even
statements
end
or
if rem(jj,2) % odd
statements
else % even
statements
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!