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

Learn moreOpportunities for recent engineering grads.

Apply TodayIncorrect

51Size

Leading solution size is 35.
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

Fail

%% assert(isempty(regexp(fileread('Rosenbrock_banana.m'),'assert.m')))

Error: Assertion failed.

2

Pass

%% x = [0; 0]; assert(isequal(Rosenbrock_banana(x),1))

Hessian = 0 0 0 0 [Warning: Function /users/msssystem19/assert.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In Rosenbrock_banana at 8 In verifyCode>evaluateCode at 231 In verifyCode at 40 In fevalJSON at 14]

3

Pass

%% x = [1; 1]; assert(isequal(Rosenbrock_banana(x),0))

Hessian = 0 0 0 0 [Warning: Function /users/msssystem19/assert.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In Rosenbrock_banana at 8 In verifyCode>evaluateCode at 231 In verifyCode at 40 In fevalJSON at 14]

4

Pass

%% x = [1; -1]; assert(isequal(Rosenbrock_banana(x),400))

Hessian = 0 0 0 0 [Warning: Function /users/msssystem19/assert.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In Rosenbrock_banana at 8 In verifyCode>evaluateCode at 231 In verifyCode at 40 In fevalJSON at 14]

5

Pass

%% x = [-1; 0.5]; assert(isequal(Rosenbrock_banana(x),29))

6

Pass

%% x = [0; 0]; [~,grad]=Rosenbrock_banana(x); assert(isequal(grad,[-2; 0]))

7

Pass

%% x = [0; 0]; [~,~,Hess]=Rosenbrock_banana(x); assert(isequal(Hess,diag([2, 200])))

8

Pass

%% x = [1; 1]; [~,grad]=Rosenbrock_banana(x); assert(isequal(grad,[0; 0]))

9

Pass

%% x = [1; 1]; [~,~,Hess]=Rosenbrock_banana(x); assert(isequal(Hess,[802, -400; -400, 200]))

10

Pass

%% x = [-1.9; 2]; correct_value = 267.6200; correct_grad = -1e3*[1.2294; 0.3220]; correct_Hess = [3534, 760; 760, 200]; [val,grad,Hess]=Rosenbrock_banana(x); assert(isequal(str2num(num2str(val)),correct_value)) assert(isequal(str2num(num2str(grad)),correct_grad)) assert(all(max(abs(Hess-correct_Hess)<1e-8)))