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

Learn moreOpportunities for recent engineering grads.

Apply TodayCorrect

147Size

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

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))

[Warning: Polynomial is badly conditioned. Add points with distinct X values, reduce the degree of the polynomial, or try centering and scaling as described in HELP POLYFIT.] [> In polyfit at 76 In spot_the_outlier at 2 In verifyCode>evaluateCode at 226 In verifyCode at 40 In fevalJSON at 14] [Warning: Polynomial is badly conditioned. Add points with distinct X values, reduce the degree of the polynomial, or try centering and scaling as described in HELP POLYFIT.] [> In polyfit at 76 In spot_the_outlier at 4 In verifyCode>evaluateCode at 226 In verifyCode at 40 In fevalJSON at 14] [Warning: Polynomial is badly conditioned. Add points with distinct X values, reduce the degree of the polynomial, or try centering and scaling as described in HELP POLYFIT.] [> In polyfit at 76 In spot_the_outlier at 6 In verifyCode>evaluateCode at 226 In verifyCode at 40 In fevalJSON at 14] ans = 3

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 = 2

3

Pass

%% 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))

ans = 5

4

Pass

%% pts = [2 5;0 4;0 0;4 6;-2 3]; outlier = 3; assert(isequal(spot_the_outlier(pts),outlier))

ans = 3

5

Pass

%% pts = [1 0; 0 1; 1 2; 1.5 2.5; 2 3; 3 4 ]; outlier = 1; assert(isequal(spot_the_outlier(pts),outlier))

[Warning: Polynomial is badly conditioned. Add points with distinct X values, reduce the degree of the polynomial, or try centering and scaling as described in HELP POLYFIT.] [> In polyfit at 76 In spot_the_outlier at 3 In verifyCode>evaluateCode at 226 In verifyCode at 40 In fevalJSON at 14] ans = 1