Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Correct

90Size
Leading solution size is 24.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
for tests=1:5
 xc_truth=randn;
 yc_truth=randn;
 r_truth=rand;
 rand_ang=randi(360,3,1)+rand(3,1); % Avoid duplicate location via rand(3,1)
 pts=[xc_truth+r_truth*cosd(rand_ang) yc_truth+r_truth*sind(rand_ang)];
 [xc,yc,r]=find_circle(pts);
 %dif=[xc yc r]-[xc_truth yc_truth r_truth]
 assert(max(abs([xc,yc,r]-[xc_truth,yc_truth,r_truth]))<1e-6,...
sprintf('Expect xc %.2f yc %.2f r %.2f  Ans:%.2f %.2f %.2f',...
  xc_truth,yc_truth,r_truth,xc,yc,r))
end
xc =
   -0.3728
yc =
   -0.2365
r =
    0.9880
xc =
   -0.2781
yc =
    0.4227
r =
    0.1366
xc =
    1.0826
yc =
    1.0061
r =
    0.3342
xc =
    0.9111
yc =
    0.5946
r =
    0.6177
xc =
   -1.6118
yc =
   -0.0245
r =
    0.1679