What's the point of 'isinf' function ?
Show older comments
In MATLAB we can use '==' operator to check whether the given variable is a finite or infinite. I'm wondering is there any advantages of using 'isinf' function ? like improvement in execution time or handling of some execptions. Any information is helpful. Thank you.
Accepted Answer
More Answers (1)
For one thing, it covers cases were the inf elements have mixed signs, thus avoiding the overhead of additional operations like abs().
isinf([-inf, 2, inf, 5])
5 Comments
Infinite_king
on 5 Jan 2024
Edited: Infinite_king
on 5 Jan 2024
isinf can be useful for complex inputs if desired that either real or imaginary part being inf should return true.
x = inf + 1i
inf == x
isinf(x)
x = 1 + 1i*inf
isinf(x)
Huh, looks like it tests the imaginary component as well !
Infinite_king
on 8 Jan 2024
Categories
Find more on Numeric Types in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!