How can I increase the precision of a variable after decimal?

조회 수: 3 (최근 30일)
Ender Rencuzogullari
Ender Rencuzogullari 2015년 12월 4일
댓글: Star Strider 2015년 12월 6일
Dear Contributers,
I am in trouble with digits. I need to tell you that I searched for long time. However I could not find the answer. I hope I can find in here. The problem is;
There is c value which is changing depends on previous operations. and there is r
let say; after operations, c=75.00002874 and r=75 when program implements c-r , the result becomes 0. Because c is taken as 75.0000 by program. I need to increase the digit numbers after decimal for c. But not by using fprintf , format long etc. Because They only affect for displaying the value on the screen. I do not need to display c or r. I need the correct result when c-r operated such as; c-r = 75.00002874 - 75 = 0.00002874
the equation of c is >>
c= hypot(X(1) , Y(1))
X(1) and Y(1) depends on previous operations, too. But their digits number after decimal is enough to evaluate the c. So I only need to increase the digits number of c so the program can take the c into the c-r operation with increased precision.
How can I do that? I am so stucked. Thanks
  댓글 수: 19
Star Strider
Star Strider 2015년 12월 5일
As always, my pleasure!
Walter Roberson
Walter Roberson 2015년 12월 6일
Please post a summary Answer and accept it.

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

답변 (1개)

Star Strider
Star Strider 2015년 12월 6일
The problem began with a previous Question (reference: how to plot tangent line from specified point to a circle ?) and the current problem arose when the point from which tangents were to be drawn was defined to be on the circle circumference, from which no tangents to the circle could be drawn.
This discussion spanned the other thread as well, in which I suggested one possible solution, that being to subtract a small amount from the radius of the circle, or alternatively add a small amount to the distance of the point from the circle. That seems to have worked, and the points on the circle where the tangent lines intercepted the circle were calculated and plotted correctly, although the resolution of the circle and other vectors did not give sufficient resolution with a point at such close proximity to the circumference of the circle to plot the tangent lines themselves correctly. My reply was:
‘That is correct. If you want to see the tangent lines touch the circle from a point that close, you have to increase the resolution of your data calculations. For instance, instead of using the default value of 100 points in the linspace function, increase it to 1000 or more as necessary to plot the tangents correctly:
v = linspace(a, b, 1000);
The calculated values of the points on the circle where the tangent lines touch the circle are correct.’
Ender Rencuzogullari replied:
‘Thank you so much. You are the best, sir ! Especially,
rr= rr - sqrt(eps);
solved my problem. the All my problems and answers which I am looking for long time are done now, under your profession.’
To which I replied ‘My pleasure’ and considered the problem resolved.
  댓글 수: 1
Star Strider
Star Strider 2015년 12월 6일
@Walter — Please edit my Answer for content and clarity as necssary. I have been too close to it too long to be able to do that efficiently just now.

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

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by