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

# Solution 262002

Submitted on 17 Jun 2013 by Richard Zapor

Correct

297Size
`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

```%%
pts=[0 0;5 0;1.8 2.4]; % 3 4 5 triangle
r_exp=2.5;
assert(abs(r-r_exp)<.001)
```

2
Pass

```%%
pts=[0 0;6 0;1.8 2.4]; % 3 x 6 triangle
r_exp=3; % Two Point Solver
assert(abs(r-r_exp)<.001)
```

3
Pass

```%%
pts=[0 0;0 1;1 2;3 0]; % r^2=2.5
r_exp=sqrt(2.5);
assert(abs(r-r_exp)<.001)
```

4
Pass

```%%
pts=[0 1; 0 3; 0 4; 2 6; 3 0; 4 5]; % r2 9.2820069
r_exp=sqrt(9.2820069 );
assert(abs(r-r_exp)<.001)
```

5
Pass

```%%
pts=[0,2;0,6;1,1;3,0;3,3;4,10;5,10;7,2;9,7]; % r2 26.6919
r_exp=sqrt(26.6919420552286 );
assert(abs(r-r_exp)<.001)
```

6
Pass

```%%
pts=[0,19;1,25;1,30;1,34;3,11;4,30;8,17;9,6;11,44;12,45;15,46;21,0;21,9;21,48;22,42;26,11;31,40;34,27;37,44;39,34;41,8;43,9;43,10;46,16;46,35;48,23]; % r2  exp 608.7807
r_exp=sqrt(608.780718525455);
assert(abs(r-r_exp)<.001)
```

7
Pass

```%%
% Random case to avoid hard coders
xc=rand;
yc=rand;
r=.5+rand;
pts=[];
% Equilateral points
pts(1,:)=[xc+r,yc];
pts(2,:)=[xc+r*cos(2*pi/3),yc+r*sin(2*pi/3)];
pts(3,:)=[xc+r*cos(-2*pi/3),yc+r*sin(-2*pi/3)];
for i=4:10
rnew=rand*r;
theta=randi(360)*pi/180;
pts(i,:)=[xc+rnew*cos(theta),yc+rnew*sin(theta)];
end
pts=pts(randperm(size(pts,1)),:);
r_exp=r;
assert(abs(r-r_exp)<.001)
```

8
Pass

```%%
% Random case to avoid hard coders
xc=rand;
yc=rand;
r=.5+rand;
pts=[];
% Equilateral points
pts(1,:)=[xc+r,yc];
pts(2,:)=[xc+r*cos(2*pi/3),yc+r*sin(2*pi/3)];
pts(3,:)=[xc+r*cos(-2*pi/3),yc+r*sin(-2*pi/3)];
for i=4:30
rnew=rand*r;
theta=randi(360)*pi/180;
pts(i,:)=[xc+rnew*cos(theta),yc+rnew*sin(theta)];
end
pts=pts(randperm(size(pts,1)),:);
r_exp=r;