determination between Inf and -Inf

조회 수: 11 (최근 30일)
Al-Hussein Abutaleb
Al-Hussein Abutaleb 2016년 7월 22일
댓글: Azzi Abdelmalek 2016년 7월 22일
Hello,
I have a matrix that contains both inf and -inf points. I'm currently using isinf() to find the locations of these points however I have no way of knowing whether it's -inf or +inf.
The reason for this is because I later replace each inf with a predetermine value (5000) and I would like to be able to replace -inf with -5000 (but so far I haven't been able to detect them. Sample code below:
data(isinf(data)) = max(model.ub); %the max here will return 5000;
Thanks Al

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 7월 22일
편집: Azzi Abdelmalek 2016년 7월 22일
a=[1 2 inf 3 -inf -4]
idx=isinf(a)
sign(a(idx))
  댓글 수: 1
Azzi Abdelmalek
Azzi Abdelmalek 2016년 7월 22일
Al-Hussein Abutaleb commented
Brilliant!
Thank you! A

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Log Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by