How to avoid NAN in a integration?

6 ビュー (過去 30 日間)
smashing
smashing 2014 年 4 月 1 日
コメント済み: smashing 2014 年 4 月 1 日
I don't know how to set the intevals of a integral to get the best precise result.
For example:This is the orginal definition of the formula.
y=integral(@(x) log2((f1(x))./(f2(x))), -inf, inf).
Note: f1(x)->0 and f2(x)->0 when x->-inf or inf, and the decreasing speeds are different.
If I use [-inf, inf] Matlab gives me NAN.
If I narrow down the inteval, Matlab gives a number. But if I increas the inteval a little bit, I get another number. So I am wondering how to deal this kind of integral calculation? How to make it as precise as possible without NAN?
Thanks a lot.
  2 件のコメント
Andrew Sykes
Andrew Sykes 2014 年 4 月 1 日
It's not clear from your description of the problem that the integral will converge. For this integral to converge, you will need;
f1(x)./f2(x) -> 1 as x -> -inf or inf
(this condition alone won't suffice, but first check that this is indeed the case).
smashing
smashing 2014 年 4 月 1 日
Hi Andrew, I tried a solution and it seems ok: y=integral(@(x) log2((f1(x))./(f2(x)+eps)+eps), -inf, inf).

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

回答 (0 件)

カテゴリ

Help Center および File ExchangePerformance and Memory についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by