Search code examples
matlabvectorequalityinfinity

Matlab checking if all vector elements == -inf


How do I do this? If I were checking for 1's I'd look at the length of the sum, but not sure how to check if all elements are equal to -infinity without looping.


Solution

  • Use all doc

    v = [-inf, -inf, -inf, -inf]
    all(v==-inf)
    
    1
    
    v = [-inf, -inf, 1]
    all(v==-inf)
    0