Cody

Problem 417. Covering area

Solution 2998459

Submitted on 27 Sep 2020 at 17:17
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 = [1 1; 1 -1; -1 1; -1 -1; 0 0]; y_correct = 4; assert(isequal(cover_area(x),y_correct))

x = 1 1 -1 -1 0 y = 1 -1 1 -1 0

Error using reshape Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension. Error in polyarea (line 46) area = reshape(abs(sum( (x([2:siz(1) 1],:) - x(:,:)).* ... Error in cover_area (line 4) s = polyarea(x,y,1) Error in Test1 (line 3) assert(isequal(cover_area(x),y_correct))

2   Fail
x = [1 1; 1 -2; -2 1; -1 -2; 2 -1; -3 0; 0.2*randn(4,2)]; y_correct = 11; assert(isequal(cover_area(x),y_correct))

x = 1.0000 1.0000 -2.0000 -1.0000 2.0000 -3.0000 -0.1204 -0.1162 -0.0493 -0.0663 y = 1.0000 -2.0000 1.0000 -2.0000 -1.0000 0 0.2422 0.1785 0.1857 0.0884

Error using reshape Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension. Error in polyarea (line 46) area = reshape(abs(sum( (x([2:siz(1) 1],:) - x(:,:)).* ... Error in cover_area (line 4) s = polyarea(x,y,1) Error in Test2 (line 3) assert(isequal(cover_area(x),y_correct))

3   Fail
x = [1 1; 1 -2; -1 1; -1 -2; 3 4; 0.2*randn(10,2)]; y_correct = 12; assert(isequal(cover_area(x),y_correct))

x = 1.0000 1.0000 -1.0000 -1.0000 3.0000 -0.4033 0.2817 -0.0922 0.0960 -0.1262 0.0335 0.0902 -0.0235 -0.2498 -0.2506 y = 1.0000 -2.0000 1.0000 -2.0000 4.0000 0.1559 -0.0615 0.1684 0.0591 -0.3603 0.3394 0.0806 -0.0996 0.2431 -0.1990

Error using reshape Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension. Error in polyarea (line 46) area = reshape(abs(sum( (x([2:siz(1) 1],:) - x(:,:)).* ... Error in cover_area (line 4) s = polyarea(x,y,1) Error in Test3 (line 3) assert(isequal(cover_area(x),y_correct))

Suggested Problems

More from this Author3

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!