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 361507

Submitted on 28 Nov 2013 by Alfonso Nieto-Castanon

Correct

16Size
Leading solution size is 10.
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
 
%%
x = 1
length_correct = 3/sqrt(10);
width_correct = 1/sqrt(10);
[width, length] = rectangle(x);
tolerance = 1e-12;
assert( abs(length-length_correct)<tolerance && abs(width-width_correct)<tolerance )
x =
     1
2
Pass
 
%%
x = 2;
width_correct = 2/sqrt(10);
length_correct = 6/sqrt(10);
[width, length] = rectangle(x);
tolerance = 1e-12;
assert(abs(length-length_correct)<tolerance && abs(width-width_correct)<tolerance)