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 144843

Submitted on 5 Oct 2012

Incorrect

63Size
Leading solution size is 26.
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 1; 0 2; 3 2; 0 3; 0 4 ];
outlier = 3;
assert(isequal(spot_the_outlier(pts),outlier))
ans =
   -1.2000    0.3000
    2.1000   -0.4000
   -0.6000   -0.1000
   -0.3000    0.2000
ans =
   -1.2000         0
    2.1000         0
   -0.6000         0
   -0.3000         0
ans =
     0     0
     0     0
     0     0
     0     0
ans =
   -0.3000    0.1000
   -0.6000    0.2000
    2.1000   -0.7000
   -1.2000    0.4000
ans =
   -0.3000   -0.1000
   -0.6000    0.3000
    2.1000   -0.3000
   -1.2000    0.1000
2
Pass
 
%%
pts = [10 -1;7 0;9.5 0.3;9 1.6;8.5 2.9];
outlier = 2;
assert(isequal(spot_the_outlier(pts),outlier))
ans =
   -0.9000    0.3000
    1.2000   -0.4000
    0.3000   -0.1000
   -0.6000    0.2000
ans =
   1.0e-15 *
         0   -0.2220
         0   -0.2776
         0   -0.4441
         0   -0.4441
ans =
    1.0000    0.1200
   -1.7500   -0.2100
    0.5000    0.0600
    0.2500    0.0300
ans =
    0.9500    0.2500
   -1.8500    0.0500
    0.8500   -0.8500
    0.0500    0.5500
ans =
    1.0500   -0.0100
   -1.9000    0.1800
    0.6500   -0.3300
    0.2000    0.1600
3
Fail
 
%%
pts = [-0.6 -6;-0.2 0;0 3;-0.8 -9;-2 1;-0.4 -3];
outlier = 5;
assert(isequal(spot_the_outlier(pts),outlier))
Error: Output argument "outlier" (and maybe others) not assigned during call to "/users/msssystem17/spot_the_outlier.m>spot_the_outlier".
4
Fail
 
%%
pts = [2 5;0 4;0 0;4 6;-2 3];
outlier = 3;
assert(isequal(spot_the_outlier(pts),outlier))
Error: Output argument "outlier" (and maybe others) not assigned during call to "/users/msssystem17/spot_the_outlier.m>spot_the_outlier".
5
Fail
 
%%
pts = [1 0; 0 1; 1 2; 1.5 2.5; 2 3; 3 4 ];
outlier = 1;
assert(isequal(spot_the_outlier(pts),outlier))
Error: Output argument "outlier" (and maybe others) not assigned during call to "/users/msssystem17/spot_the_outlier.m>spot_the_outlier".