Determining if the length of an array is even or odd?

6 vues (au cours des 30 derniers jours)
Joe
Joe le 7 Avr 2013
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.

Réponse acceptée

Image Analyst
Image Analyst le 7 Avr 2013
if rem(length(A), 2) == 1
% It's odd
end

Plus de réponses (0)

Catégories

En savoir plus sur Data Types dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by