How to increase the precision of Matlab (compared to Fortran) ???
Mostrar comentarios más antiguos
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 comentario
Jan
el 18 de Nov. de 2012
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).
Respuestas (3)
Walter Roberson
el 18 de Nov. de 2012
2 votos
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
el 18 de Nov. de 2012
2 votos
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
el 20 de Jul. de 2013
0 votos
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 comentarios
Jan
el 20 de Jul. de 2013
The suggested tool is commercial. Therefore I'm in doubt, if this is an advertisement.
Pavel Holoborodko
el 21 de Jul. de 2013
This is just an answer to the asked question without any purpose of deceiving.
There is a special toolbox which addresses particular problem described in question - that is all. Should this information be hidden just because developers charge money to fund further development and feed their families?
MATLAB is commercial product itself and it is known thanks to intensive advertisement.
Jan
el 21 de Jul. de 2013
@Pavel: I did not thought of any kind of deceiving. Advertising does not mean cheating. Your rhetoric question about feeding families is funny. Instead of discussing ethical questions, let me mention the terms of use of this forum:
2.iv Content that you submit must be offered free of charge. You may not use the Site to sell or market your products or services to others.
I'm not 100% sure, but I have the impression that you advertise your own product aggressively in different Matlab forums. It is not the job of the editors to check this, therefore I flag your answer now to let the admins check it.
Please do not get me wrong: A powerful multi-precision toolbox is a very important enhancement and might be useful for many Matlab programmers. I hope that the authors of this tool get rich and the users produce excellent scientific results with it. But this forum is not the right place for advertisements, because there is only a small step to that what we all consider as spam. I estimate roughly, that 90 to 100% of the top 30 contributors in this forum are professional Matlab programmers and they all hesitate to advertise their own work for very good reasons, except for the freely available FEX submissions.
Pavel Holoborodko
el 22 de Jul. de 2013
I am glad you find my comment funny.
Still I don't see why precise and relevant answer to the question can be tagged as spam or "aggressive advertisement".
"MATLAB Answers provides a collaborative environment for finding the best answers to your questions about MATLAB, Simulink, and related products."
Please consider multi-precision toolbox as a "related product" in this regard. There are even direct questions about mp-toolbox asked on MATLAB Answers (e.g. advanpix-multi-precision-toolbox Advanpix Multi precision toolbox).
Hope you won't accuse authors of such questions for "aggressive advertisement" or spam.
@Pavel: You can read in my comment for the flag: "I'm convinced, that this is not spam". I think, that advertising your own product without mentioning here (in opposite to the thread you've posted the link to) that you are the author (if this is the fact?) and its commercial nature is "using the Site to market your product to others". It is TMWs decision, if "related products" include only the ones created by TMW or not.
My intention is to keep this forum clean and I do not want professional programmers to advertise their products here or in the FileExchange comnments, even if they feed their families (as we all do).
I leave the discussion now, because it is not related to Matlab anymore.
Daniel Shub
el 31 de Jul. de 2013
To me it is about disclaimers and quality of the answer. Pavel do you "work for" advanpix? If so, I think you should mention it. Further, an example would go a long way to demonstrating what you mean (especially since one cannot just download the product and try it out). For example a simple Fortran program showing the result of a REAL*16 opperation, the standard MATLAB result, and the result with the MP toolbox..
Wendy Fullam
el 31 de Jul. de 2013
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
el 31 de Jul. de 2013
@Wendy: Thanks, this clears my question completely and I've removed the my flag.
Categorías
Más información sobre Parallel and Cloud en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!