How does 'subs' in MATLAB work with negative large fractional number?

1 回表示 (過去 30 日間)
Rahul Bhattacharya
Rahul Bhattacharya 2015 年 4 月 19 日
コメント済み: Rahul Bhattacharya 2015 年 4 月 19 日
syms x y A A=x^2*y; subs(A,{x y},{4 2e-8})
ans =
3022314549036573/9444732965739290427392 ----- wrong result!!!
syms x y A A=x^2*y; subs(A,{x y},{4 2e8})
ans =
3200000000 ------ correct result!!
How do I resolve this type of problem? Please help.

採用された回答

Mischa Kim
Mischa Kim 2015 年 4 月 19 日
Rahul, the first result is correct as well. MATLAB simply outputted the result as a fraction. Use
double(subs(A,{x y},{4 2e-8}))
ans =
3.200000000000000e-07
which is the same as
3022314549036573/9444732965739290427392
ans =
3.200000000000000e-07

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSymbolic Variables, Expressions, Functions, and Preferences についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by