Elements Of Electromagnetics
Elements Of Electromagnetics
7th Edition
ISBN: 9780190698614
Author: Sadiku, Matthew N. O.
Publisher: Oxford University Press
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

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.
expand button
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
Check Mark
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.

Knowledge Booster
Background pattern image
Mechanical Engineering
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
Text book image
Elements Of Electromagnetics
Mechanical Engineering
ISBN:9780190698614
Author:Sadiku, Matthew N. O.
Publisher:Oxford University Press
Text book image
Mechanics of Materials (10th Edition)
Mechanical Engineering
ISBN:9780134319650
Author:Russell C. Hibbeler
Publisher:PEARSON
Text book image
Thermodynamics: An Engineering Approach
Mechanical Engineering
ISBN:9781259822674
Author:Yunus A. Cengel Dr., Michael A. Boles
Publisher:McGraw-Hill Education
Text book image
Control Systems Engineering
Mechanical Engineering
ISBN:9781118170519
Author:Norman S. Nise
Publisher:WILEY
Text book image
Mechanics of Materials (MindTap Course List)
Mechanical Engineering
ISBN:9781337093347
Author:Barry J. Goodno, James M. Gere
Publisher:Cengage Learning
Text book image
Engineering Mechanics: Statics
Mechanical Engineering
ISBN:9781118807330
Author:James L. Meriam, L. G. Kraige, J. N. Bolton
Publisher:WILEY