MATLAB: Program that separates even and odd numbers and shows them in two vectors.

homeworkodd and even

The program must throw 100 in two vectors, in one the 50 pairs will be shown and in the other 50 odd. All this using the cilco for and conditions if they are necessary. I already got him to throw the numbers but to separate them.

Best Answer

n = (1:100)';
lo = rem(n,2)==1;
pares = n(~lo);
impares = n(lo);