필터 지우기
필터 지우기

Is there a way to reduce the precision of Matlab overall?

조회 수: 4 (최근 30일)
Danny Miranda
Danny Miranda 2016년 10월 12일
댓글: Danny Miranda 2016년 10월 12일
For my Power II course my professor has us doing Power Flow Analysis, and to speed things up I've coded an entire assignment into Matlab, and while my answers seem close to his own, he warns that he only used 4 decimal point precision. I'm curious if there is an easy way to reduce the precision of Matlab to better approximate my professor's answers? Might not be possible, but figured I would ask.

채택된 답변

Walter Roberson
Walter Roberson 2016년 10월 12일
There is no global preference of any kind to reduce precision.
You could experiment with feature('setprecision'); see http://www.mathworks.com/matlabcentral/newsreader/view_thread/155369 and note that system_dependent() and feature() are the same thing.
You could also program using symbolic variables, in which case you can control the number of decimal digits used.
  댓글 수: 1
Danny Miranda
Danny Miranda 2016년 10월 12일
That's what I was afraid of. Thanks for the info, I'll definitely that out!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matthew Eicholtz
Matthew Eicholtz 2016년 10월 12일
편집: Matthew Eicholtz 2016년 10월 12일
Here is a simple way to change the precision of a result:
n = 4; % number of desired decimal points
x = round(x*10^n)/10^n;
Obviously, this doesn't change some global precision preference (I don't know if there is one), but it should help with your assignment.
  댓글 수: 1
Danny Miranda
Danny Miranda 2016년 10월 12일
I was playing around with this one earlier, but was hoping there would be some form of global precision preference. Thanks for your time!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with MuPAD에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by