Converting instances of NaN to 0 and setting bold as reminder

조회 수: 1 (최근 30일)
I'm working with signal detection, and frequently the denominator of my fractions is zero (e.g., Sensitivity = True Positive / (True Positive + False Positive)). When the denominator is 0, this returns NaN. For further analysis, I'd like to convert NaN to 0, but because these 0's will be meaningfully different from other cases (e.g., TP = 0, FP = 1; so, 0 / (0 + 1) = 0), I'd like to set these values and any further products of them to bold font.
Question 1: Does this solution make sense mathematically? Some stackexchange forums recommended setting NaN values in this case to 0, but I'd feel better about it if I knew the Matlab community agreed.
Question 2: How can I communicate this to Matlab? The example code below returns Inf rather than NaN, but the if statement doesn't do anything to "quo". By itself, "quo(isinf(quo)) = 0" works, but setBold does not and I'm not sure how to indicate that I want all further computations from that 0 to also be bold.
a = [2 4 6]
b = [4 2 0]
quo = a ./ b
if quo == Inf
quo(isinf(quo)) = 0
setBold(quo, 'true')
end
Thank you in advance!
  댓글 수: 2
Image Analyst
Image Analyst 2020년 3월 20일
Exactly what will be bolded? Are you displaying quo on a user interface of some kind?
May_the_degrees_of_freedom_be_with_you
I apologize for the delayed response. Things have been crazy.
In this example, dividing a/b returns [0.5, 2, Inf]. I'm working to develop code that will set to bold every instance of Inf and convert every instance of Inf to bold 0's. Here, that would just be one instance of Inf (6/0 = Inf), but I'll be applying this to a very large matrix with many NaN values produced by dividing by 0 in the same manner.
Thank you!

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

답변 (0개)

카테고리

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