# any

## Purpose

Test arrays for logical conditions.

## Synopsis

    Y = any(X)

## Description

`any(X)`, where `X` is a vector, returns 1 if any of the elements of `X` are nonzero. It returns 0 if all the elements are zero. For matrices, `any(X)` operates on the columns of `X`, returning a row vector of 1s and 0s.

## Examples

This function is particularly useful in `if` statements

    if any(A < 0.5)
        do something
    end

because an `if` wants to respond to a single condition, not a vector of possibly conflicting suggestions. Applying the function twice, as in `any(any(A))`, always reduces the matrix to a scalar condition.

## See Also

    &, |, ~, all

(c) Copyright 1994 by The MathWorks, Inc.