How to convert NaN value to 'zero' ?

6 ビュー (過去 30 日間)
Ararat Cetinkaya
Ararat Cetinkaya 2020 年 3 月 23 日
コメント済み: Image Analyst 2020 年 3 月 23 日
Hi Everybody,
I have an equation like this "Enthropy = (-p2/b)*log2(p2/b)". p2 values changing according to another equation and When p2 value gets '0', Enthropy value gets to NaN. is there any way to Conver this NaN to '0' value?
For example
when : p2/b = 4
Enthropy = -4*log2(4) = -8
when : p2/b = 0
Enthropy = -0*log2(0) = 0

回答 (1 件)

darova
darova 2020 年 3 月 23 日
Use isnan
Enthropy(isnan(Enthropy)) = 0;
  3 件のコメント
darova
darova 2020 年 3 月 23 日
I don't understand
Image Analyst
Image Analyst 2020 年 3 月 23 日
Yes, of course. Why would it not be?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by