Cody

# Problem 43290. Calculate numerical integration.

Solution 1250873

Submitted on 14 Aug 2017
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
x=0:0.01:1; y=@(x)x.^2 z_correct = 0.3334 assert(abs(integralx2(x,y)-z_correct)<0.001)

y = function_handle with value: @(x)x.^2 z_correct = 0.3334

Error using max Invalid data type. Second argument must be numeric or logical. Error in trapz (line 41) perm = [dim:max(ndims(y),dim) 1:dim-1]; Error in integralx2 (line 2) z=trapz(x,y); Error in Test1 (line 4) assert(abs(integralx2(x,y)-z_correct)<0.001)

2   Fail
x=0:0.01:1; y=@(x)x.^3 z_correct = 0.25 assert(abs(integralx2(x,y)-z_correct)<0.001)

y = function_handle with value: @(x)x.^3 z_correct = 0.2500

Error using max Invalid data type. Second argument must be numeric or logical. Error in trapz (line 41) perm = [dim:max(ndims(y),dim) 1:dim-1]; Error in integralx2 (line 2) z=trapz(x,y); Error in Test2 (line 4) assert(abs(integralx2(x,y)-z_correct)<0.001)