NaN for zero divide by zero.
4 ビュー (過去 30 日間)
古いコメントを表示
Will illustrate with an example, I.e:
a = (0:0.1:1); b = (1-a)*2./(1-a);
Matlab will output the end value in b as NaN, when in reality b should converge to 2 for a = 1.
How can I avoid this?
0 件のコメント
採用された回答
Matt Fig
2011 年 4 月 6 日
There are two things to remember when looking at this problem.
1. A function having a limit as the independent variable approaches a point does not imply that the function value at that point is defined. You plugged in for the function value at that point. The fact that you get NAN says nothing about the limit of the function as the independent variable approaches that point.
2. NAN is the correct value when evaluating the function at that point. This is a standard double precision definition.
4 件のコメント
その他の回答 (3 件)
Walter Roberson
2011 年 4 月 6 日
In order to avoid this, you will need to use the symbolic toolbox.
MATLAB is giving the correct numeric answer according to IEEE 754 floating point definitions. MATLAB works with actual values computed on real machines, not with limits or ideal values. See for example this portion of the FAQ
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!