Converting instances of NaN to 0 and setting bold as reminder
1 view (last 30 days)
Show older comments
May_the_degrees_of_freedom_be_with_you
on 19 Mar 2020
Commented: May_the_degrees_of_freedom_be_with_you
on 30 Mar 2020
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 Comments
Image Analyst
on 20 Mar 2020
Exactly what will be bolded? Are you displaying quo on a user interface of some kind?
Answers (0)
See Also
Categories
Find more on Numeric Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!