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

Solution 174707

Submitted on 8 Dec 2012 by Binbin Qi

Correct

31Size
Leading solution size is 15.
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
 
%%
d=200; b=100; p=0.5;
mm = telescope(d,b,p)
mm_correct = 21
assert(abs(round(abs(mm))- mm_correct)<1000*eps)
mm =
   20.6143
mm_correct =
    21
2
Pass
 
%%
d=100; b=200; p=0.5;
mm = telescope(d,b,p)
mm_correct = 21
assert(abs(round(abs(mm))- mm_correct)<1000*eps)
mm =
  -20.6143
mm_correct =
    21
3
Pass
 
%%
d=100; b=100; p=0.5;
mm = telescope(d,b,p)
mm_correct = 0
assert(round(abs(mm))== mm_correct)
mm =
     0
mm_correct =
     0