2

So I have a double loop through a matrix, which reads the contents of each cell and if the cell's content is greater than zero it does something. The problem is there are also not real numbers in the matrix, such as Inf. What I want is the following:

 if (Cell < 0 or inf) {do something}

1 Answer 1

3

Use:

if (Cell < 0 || is.infinite(Cell)) { ... }

Similarly to the code in your question, this checks whether the number is less than zero; it is trivial to change the condition to check whether the numer is greater than zero.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.