フィルターのクリア

Matlab approximation of 0 for small numbers

8 ビュー (過去 30 日間)
Mark
Mark 2013 年 11 月 27 日
コメント済み: Mark 2014 年 1 月 15 日
Hi,
I'm attempting to check for error convergence, but I'm entering an infinite loop, and I believe the culprit is Matlab approximating a small number as 0. These numbers are used in the calculation of my error,
xx = 1 - ((ff*ddff)/(2*dff*dff))
bb = ((ff*ddff)/(2*dff*dff)) % for display and debugging purposes only
But for some early iterations I get stuck in an infite loop and the outputs are
xx =
1
bb =
-1.2633e-08
This in turn affects the error calculation (decreasing the tolerance of my error fixes the situation but this is not desireable). Clearly the theoretical answer of xx is not exactly 1 (as the output format suggests, shouldn't it display 1.000?). Would matlab be approximating bb = 0 in this case? Any way to change the approximation tolerance? Any help is appreciated.
Mark

採用された回答

Mark
Mark 2014 年 1 月 10 日
I had read data in as %f32 instead of %f64 thus not recognizing that small of a number
  2 件のコメント
Marc
Marc 2014 年 1 月 10 日
How is that an "accepted" answer? You did not ask us how to read in data.
Mark
Mark 2014 年 1 月 15 日
I asked why matlab was approximating numbers as zero when it should have been keeping its finite value. The format of the data was important because when calculations gave such small enough answers it would register as 0. I know how to read in data, my question was how matlab handles it. See floating point double vs. floating point single.

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

その他の回答 (1 件)

Sean de Wolski
Sean de Wolski 2013 年 11 月 27 日
while abs(bb)<10^-7
etc.
end
?
  2 件のコメント
Mark
Mark 2013 年 11 月 27 日
the xx value is used in a different calculation where small changes in xx would have a larger change in the resulting calculation. It is the difference between these 2 iterations/calculations that I'm trying to get to converge (i.e. <1e-6)
Sean de Wolski
Sean de Wolski 2013 年 11 月 27 日
Then include that expression inside of the abs()

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

カテゴリ

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