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

3 views (last 30 days)
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 Comments

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 6 Dec 2015
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 Comment
Star Strider
Star Strider on 6 Dec 2015
@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.

Sign in to comment.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!