script is supposed to read in three floating point values (a, b, and c) which represent the lengths of three sides of a triangle from user. Then computes the area of the triangle according to the equation: area = √s(sa)(s — b)(s — c) where s is half of the sum of the three sides. Also, the code displays the area in the command window. Our programmer did her best to make some intentional mistakes and give you a hard time. Please forgive her in your heart and debug the code using MATLAB Code Analyzer and Debugger. Note: Check if the calculated area value is correct (try a triangle with an area easy to calculate). Some errors are grammatical errors, and some are logical errors. The logical ones are more dangerous since MATLAB does not give us any error and we do not notice them unless we check our calculation manually.

Elements Of Electromagnetics
7th Edition
ISBN:9780190698614
Author:Sadiku, Matthew N. O.
Publisher:Sadiku, Matthew N. O.
ChapterMA: Math Assessment
Section: Chapter Questions
Problem 1.1MA
icon
Related questions
Question
100%
Please provide the correct matlab code for the following question.
script is supposed to read in three floating point values (a, b, and c) which represent the lengths
of three sides of a triangle from user. Then computes the area of the triangle according to the
equation:
area =
√√s(sa)(sb)(s — c)
where s is half of the sum of the three sides. Also, the code displays the area in the command
window.
Our programmer did her best to make some intentional mistakes and give you a hard time.
Please forgive her in your heart and debug the code using MATLAB Code Analyzer and
Debugger.
Note: Check if the calculated area value is correct (try a triangle with an area easy to
calculate). Some errors are grammatical errors, and some are logical errors. The logical ones
are more dangerous since MATLAB does not give us any error and we do not notice them
unless we check our calculation manually.
Transcribed Image Text:script is supposed to read in three floating point values (a, b, and c) which represent the lengths of three sides of a triangle from user. Then computes the area of the triangle according to the equation: area = √√s(sa)(sb)(s — c) where s is half of the sum of the three sides. Also, the code displays the area in the command window. Our programmer did her best to make some intentional mistakes and give you a hard time. Please forgive her in your heart and debug the code using MATLAB Code Analyzer and Debugger. Note: Check if the calculated area value is correct (try a triangle with an area easy to calculate). Some errors are grammatical errors, and some are logical errors. The logical ones are more dangerous since MATLAB does not give us any error and we do not notice them unless we check our calculation manually.
Expert Solution
Step 1

Here's a sample MATLAB script that implements the logic you described:

% Read in the three sides of the triangle
a = input('Enter the length of side a: ');
b = input('Enter the length of side b: ');
c = input('Enter the length of side c: ');

% Calculate the semi-perimeter of the triangle
s = (a + b + c) / 2;

% Calculate the area of the triangle
area = (s * (s - a) * (s - b) * (s - c))^(1/2);

% Display the area of the triangle
disp(['The area of the triangle is: ', num2str(area)])

 

This code prompts the user to enter the length of the three sides of the triangle, calculates the semi-perimeter 's' and the area of the triangle using the equation you provided, and then displays the area in the command window.

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Numerical Calculations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, mechanical-engineering and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Elements Of Electromagnetics
Elements Of Electromagnetics
Mechanical Engineering
ISBN:
9780190698614
Author:
Sadiku, Matthew N. O.
Publisher:
Oxford University Press
Mechanics of Materials (10th Edition)
Mechanics of Materials (10th Edition)
Mechanical Engineering
ISBN:
9780134319650
Author:
Russell C. Hibbeler
Publisher:
PEARSON
Thermodynamics: An Engineering Approach
Thermodynamics: An Engineering Approach
Mechanical Engineering
ISBN:
9781259822674
Author:
Yunus A. Cengel Dr., Michael A. Boles
Publisher:
McGraw-Hill Education
Control Systems Engineering
Control Systems Engineering
Mechanical Engineering
ISBN:
9781118170519
Author:
Norman S. Nise
Publisher:
WILEY
Mechanics of Materials (MindTap Course List)
Mechanics of Materials (MindTap Course List)
Mechanical Engineering
ISBN:
9781337093347
Author:
Barry J. Goodno, James M. Gere
Publisher:
Cengage Learning
Engineering Mechanics: Statics
Engineering Mechanics: Statics
Mechanical Engineering
ISBN:
9781118807330
Author:
James L. Meriam, L. G. Kraige, J. N. Bolton
Publisher:
WILEY