How to get Matlab to return answers with ten-digit accuracy?

16 ビュー (過去 30 日間)
Noob
Noob 2020 年 9 月 17 日
コメント済み: Noob 2020 年 9 月 18 日
Hi,
Answers returned by Matlab (e.g. from the ode45 solver, or from the wrapTo2Pi function that maps accumulating angles to [0, 2pi] ) seem to be within four digits of accuracy; that is, it rounds to four digits after the decimal place.
I'm currently studying convergence and root-finding and would like ten-digit accuracy -- so, a bit beyond the standard function tolerance of 1e-6 or 1e-7.
How can I get Matlab answers with ten-digit accuracy?
Thanks,

回答 (2 件)

Mario Malic
Mario Malic 2020 年 9 月 17 日
編集済み: Mario Malic 2020 年 9 月 17 日
Write this on start of your script
format long
If you're reading the values from the workspace, find tab 'View' and under 'Format', click 'Long Fixed Decimal'.
Edit: this only changes displayed output, see James' answer.
  10 件のコメント
Noob
Noob 2020 年 9 月 18 日
Hi James,
Ok, will do - and thanks so much for your help.
Noob
Noob 2020 年 9 月 18 日
Hi Walter,
Ok, thanks so much - have a good night.

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


William
William 2020 年 9 月 17 日
The answers returned by Matlab actually have the full available precision, but for display purposes they are printed in the command window with a much smaller precision. You can change this default behavior by typing 'format long' or 'format longEng' in the command window.
  1 件のコメント
Walter Roberson
Walter Roberson 2020 年 9 月 17 日
Personally I favor format long g

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by