Cody

Problem 45271. Calculate triangle area

Solution 2101208

Submitted on 21 Jan 2020 by Binbin Qi
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   Pass
coords=[0 0;1 0; 1 1; 0 1]; lnods=[ 1 2 4; 2 3 4]; y_correct = [0.500;0.500]; assert(isequal(areas(coords,lnods),y_correct))

ans = 0.5000 0.5000

2   Pass
coords=[0 0;1 0; 1 1; 0 1; 0.5 0.5]; lnods=[ 1 2 5; 2 3 5;3 4 5;4 1 5]; y_correct = [0.2500;0.2500;0.2500;0.2500]; assert(isequal(areas(coords,lnods),y_correct))

ans = 0.2500 0.2500 0.2500 0.2500