You simply have to go back to the definition of odd and even. An (integer) number is even if it is divisible by 2, odd otherwise. Divisible by 2 means that the remainder when divided by 2 is 0. That is easy to test, the function to get the remainder isrem (or you can usemod).
As with many things in matlab you do not need a loop, the functions work on vector / matrices
Best Answer