I have an issue with the format of number when i use mean2

1 回表示 (過去 30 日間)
shiraz karray
shiraz karray 2016 年 1 月 29 日
コメント済み: Walter Roberson 2016 年 1 月 29 日
Hi i m a new user in matlab. I have a problem when i want to calculate
y=mean2((x-mean2(x))/std2(x))
In fact, i should obtain y=0 , but when i use for example this matrix
x=[10 10 9.2 1;8.33 11.66 29 10;4 10 10 2];
i obtain y=-5.5511e-17! could you help me please

採用された回答

Ingrid
Ingrid 2016 年 1 月 29 日
this is very common to floating point operations and basically y == 0 if you compare it to the eps value. You should never compare directly if a variable is equal to zero for this reason but always use abs(y) < eps
  3 件のコメント
shiraz karray
shiraz karray 2016 年 1 月 29 日
Thank you so much for your answer.
Walter Roberson
Walter Roberson 2016 年 1 月 29 日
There is a whole branch of mathematics that has to do with analyzing how small the "arbitrarily_small_threshold" should be, and how to know when you can stop adding terms from a theoretically infinite series.
The situation is like noticing,
"1/3 = 0.33333, so 2*(1/3) = 0.66666, so 3*(1/3) must = 0.99999 so why isn't that 1.00000?"

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

その他の回答 (0 件)

カテゴリ

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