필터 지우기
필터 지우기

What's the point of 'isinf' function ?

조회 수: 3 (최근 30일)
Infinite_king
Infinite_king 2024년 1월 5일
답변: Infinite_king 2024년 1월 8일
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.

채택된 답변

Infinite_king
Infinite_king 2024년 1월 8일
Reason 1:-
As @Paul and @Walter Roberson pointed out, 'isinf' will make it easier to check for inf values when complex numbers are involved.
Note :- I will add more reasons if I come across any in the future.

추가 답변 (1개)

Matt J
Matt J 2024년 1월 5일
편집: Matt J 2024년 1월 5일
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])
ans = 1×4 logical array
1 0 1 0
  댓글 수: 5
Paul
Paul 2024년 1월 5일
As documented: isinf
"If A contains complex numbers, isinf(A) contains 1 for elements with infinite real or imaginary part, and 0 for elements where both real and imaginary parts are finite or NaN."
Infinite_king
Infinite_king 2024년 1월 8일
Thanks for the comments @Paul and @Walter Roberson. I guess that is a good enough reason to use 'isinf' instead of '==' operator.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by