Austin
Austin

Reputation: 7339

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.

Upvotes: 0

Views: 63

Answers (1)

eyllanesc
eyllanesc

Reputation: 244182

Use all doc

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

1

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

Upvotes: 2

Related Questions