How do you find radius from input circle?

1 view (last 30 days)
I wrote a code like given below to get a circle equation from user and i need to find radius to make some calculation.(exp :2*x^2 + 2*y^2 = 8)
circle = input('Enter for circular path: ','s') ;
C = str2sym(circle) ;

Accepted Answer

Matt J
Matt J on 5 Dec 2022
Edited: Matt J on 5 Dec 2022
syms x y real
syms r real positive
c=2*(x-3)^2 + 2*(y+7)^2 == 8;
c0=str2sym(extractBefore(char(c),'=='));
sol0=solve(c0,[x,y]) %center of circle
sol0 = struct with fields:
x: 3 y: -7
c=subs(c,[x,y],[r+sol0.x,sol0.y]);
radius=double( solve(c,r) )
radius = 2

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!