~~~~~~~~~~~~~~~~~~~Please use MATLAB to answer the following questions, thank yo
ID: 3802393 • Letter: #
Question
~~~~~~~~~~~~~~~~~~~Please use MATLAB to answer the following questions, thank you!~~~~~~~~~~~~~~~~~~~
The area of a triangle of sides a, b and c can be computed as follows: A s (s a) s b) Cs -c) and s Write a function (call it triareal) that asks the user to input the three sides of a triangle one by one (that means you need to use the input function) and compute the area of the triangle. The function does not return any value. Use the display function to display the A and the s values so we can see them on your computer display. Test your function with a 21, b 12, and c- 22 3. Create a new function and call it triarea2 that is a modification of your function in 2 to accept three input arguments: a, b and c and returns two outputs s and A. (this means triarea2 will not have any input functions). Test your function as follows: Is, A triarea2 21, 21,32) Present your resultsExplanation / Answer
2.
function triarea1(a,b,c)
s=(a+b+c)/2;
A=sqrt(s*(s-a)*(s-b)*(s-c));
disp("Perimeter is ");
disp(s);
disp("Area of triangle is");
disp(A);
end
%TRIANGLE calculates perimeter and area
a=input('Please input side 1: ');
b=input('Please input side 2: ');
c=input('Please input side 3: ');
triarea1(a,b,c);
3.
function [s A]=triarea2(a,b,c)
%TRIANGLE calculates perimeer and area
s=(a+b+c)/2;
A=sqrt(s*(s-a)*(s-b)*(s-c));
end
%Test_triangle
a=input('Please input side 1: ');
b=input('Please input side 2: ');
c=input('Please input side 3: ');
[s A ]=triarea2(a,b,c);
disp("Perimeter is ");
disp(s);
disp("Area of triangle is");
disp(A);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.