MATLAB: How to find out if a number is even or not
even numbers
I know in C language, for any number x using x%2 will calculate the remainder when x is divided by 2, which will help decipher whether its even or not.
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