Is it overflow?how can I input 2.5e-6?

1 回表示 (過去 30 日間)
Shaonong Wei
Shaonong Wei 2020 年 11 月 24 日
編集済み: John D'Errico 2020 年 11 月 24 日
  1 件のコメント
John D'Errico
John D'Errico 2020 年 11 月 24 日
編集済み: John D'Errico 2020 年 11 月 24 日
Moved answer by @Shaonong Wei into a comment.
If you want to add information to your question, then either edit your question or add a comment on your question.

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

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 11 月 24 日
編集済み: Ameer Hamza 2020 年 11 月 24 日
This happens because of the way MATLAB parses the expression vpa(2.5e-6). First, MATLAB converts 2.5e-6 into a double datatype, and due to the finite precision of double(), you don't exactly get 2.5e-6. And only after that, MATLAB converts it to symbolic. In the second case, 2.5e-5 can be exactly represented, and thus, the problem does not occur. The workaround is to pass the 2.5e-6 as a char array
vpa('2.5e-6')

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by