what is the difference between manually generated data and loaded data or random data?

If we have a matrix stated as below a =
-0.3252 0.1231 -0.1236
0.3690 -0.3574 0.3214
0.8524 -1.2658 -1.3698
then we would have
EDU>> a(2,1)==0.3690
ans =
1
But if we have a matrix which contains random numbers generated by MATLAB such as b=rand(3,3)
b =
0.2293 0.1496 0.0159
0.1822 0.2027 0.9575
0.1664 0.9550 0.0257
then very suprisingly we would have
b(2,1)==0.1822
ans =
0
I came up to this problem while using the load data.mat command. In case I load the data it would face the same problem as randomly generated data.Can you please proide me an answer for this problem. Thank you

 採用された回答

Arnaud Miege
Arnaud Miege 2011 年 5 月 19 日

0 投票

3 件のコメント

Maryam
Maryam 2011 年 5 月 19 日
still I have
a
a =
0.1822
EDU>> areEssentiallyEqual = abs(a-0.1822) < eps(a)
areEssentiallyEqual =
0
Arnaud Miege
Arnaud Miege 2011 年 5 月 19 日
The error is with eps(a). Just use eps:
>> a = 0.1822
a =
0.1822
>> abs(a-0.1822)<eps
ans =
1
Arnaud Miege
Arnaud Miege 2011 年 5 月 19 日
You're trying to index eps with a.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Random Number Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by