MATLAB: Determining if the length of an array is even or odd

arrayevenfunctionlengthodd

How do i determine if the length of an array is even or odd? Is there a specific function that does this? I know length(A) gives you the length of an array, but for a function I am creating, whether the length of an array A is even or odd is a condition that must be satisfied for the function to compute its output.

Best Answer

if rem(length(A), 2) == 1
% It's odd
end
Related Question