hw12_problem3

hw12_problem3 - heron_A = sqrt(s*(s side_a)*(s side_b)*(s...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
function [heron_area] = TriArea(side_a,side_b,side_c)  % This function calculates the area of a triangle given the lengths of the   % three sides using Heron's equation.  % INPUT ARGUMENTS:   side_a = the length of side a of the triangle  %                    side_b = the length of side b of the triangle  %                    side_c = the length of side c of the triangle  % OUTPUT ARGUMENTS:  heron_area = the area of the triangle  % ---- Calculation Section ----     fprintf('One of the sides is negative or zero')               elseif      s = (side_a+side_b+side_c)/2;  % the half perimeter of the triangle              
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: heron_A = sqrt(s*(s side_a)*(s side_b)*(s side-c)); end % Line #: 11 % Error: the logic incorrectly uses & conditions % Fix: change to side_a || side_b || side_c. % Line #: 13 % Error: uses elseif condition rather than else condition % Fix: change to else. % Line #: 15 % Error: the variable heron_A not returned by the function % Fix: change the variable to heron_area. % Line #: 15 % Error: undefined variable side-c % Fix: change the variable to side_c. % Line #: 11/12 % Error: if a side has negative length, heron_area not defined so function has undefined output. % Fix: add an initialization for heron_area to line 9....
View Full Document

Page1 / 2

hw12_problem3 - heron_A = sqrt(s*(s side_a)*(s side_b)*(s...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online