How to increase the precision of Matlab (compared to Fortran) ???

4 ビュー (過去 30 日間)
Zheng
Zheng 2012 年 11 月 17 日
Hi,
I am using Matlab to translate subroutines coded by FORTRAN. However I found that the truncation error of matlab is very important, it means the precision of matlab can not be comprared to Frotran.
I tried format command, it does not work. Anyone knows how to increase the precision of matlab?
Regards
Zheng Li
  1 件のコメント
Jan
Jan 2012 年 11 月 18 日
The question would be more clear, if you explain "truncation error of Matlab is very important" with an explicit example. Currently it seems, like you confuse the internal representation of numbers (double is exactly the same as real*8) and the output to the command window (affected by the format command).

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

回答 (3 件)

Walter Roberson
Walter Roberson 2012 年 11 月 18 日
MATLAB's "double" has the same precision as Fortran's REAL*8.
MATLAB does not have a numeric class equivalent to REAL*16.

Ben Barrowes
Ben Barrowes 2012 年 11 月 18 日
What do you mean when you say "compare"? "format long" in matlab should give many digits of display. In any case, like Strider says, matlab default double is the same precision as fortran's real*8. If you need arbitrary precision in matlab (but slow calculation) try the multiple precision toolbox:
If you are converting fortran to matlab, try f2matlab:
it can get you 95% of the way to working m-code.

Pavel Holoborodko
Pavel Holoborodko 2013 年 7 月 20 日
This addon: Multiprecision Computing Toolbox for MATLAB allows programming with arbitrary precision.
It also provides fast quadruple precision mode (equivalent to REAL*16) in particular.
  8 件のコメント
Wendy Fullam
Wendy Fullam 2013 年 7 月 31 日
Hi all, I’m the technical marketing product manager of MATLAB Answers. Thanks, Pavel, for sharing the pointer to an add-on toolset which might help address Zheng’s question. Thanks, Jan, as well, for keeping an eye on the integrity of the Answers community. While MathWorks certainly does not want Answers to become an advertising mechanism for software distributors, we do encourage the offering of assistance to our customers, even when in the form of pointing to outside tools. We appreciate both of your perspectives, and believe each adds value to the general Answers audience.
Pavel, MathWorks offers a Connections program, which works with third-party organizations that develop and distribute complementary, commercially-available products and services based on MATLAB and Simulink. I’d like to encourage you to look into this venue as a means of raising awareness of this software capability: http://www.mathworks.com/products/connections/join/index.html . If this software provides the capability noted above, we’d certainly like to help spread the word. I’d also encourage you to share some code or examples from the toolset which might further assist Zheng, to enhance the value of the answer provided.
Jan
Jan 2013 年 7 月 31 日
@Wendy: Thanks, this clears my question completely and I've removed the my flag.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by