Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a MATLAB script M-file named TriangleType that will load a file of triangl

ID: 3757601 • Letter: W

Question

Write a MATLAB script M-file named TriangleType that will load a file of triangles, and use the function from Part 1 to determine if the triangles are acute or obtuse. A message should be printed to the screen for each triangle. The triangles will be contained in a text file named Triangles.txt. This file will have three columns, one for each side. Every row in the file will correspond to a triangle. The triangles will be either acute or obtuse—there will be no right triangles, nor any non triangles.

Example: Given a text file with this data: The script file should produce the following output to the Command Window: >>

TriangleType The 8 14 8 triangle is obtuse

The 6 8 12 triangle is obtuse

The 5.5 6.7 9.8 triangle is obtuse

The 24 10 24 triangle is acute

Code Requirements: • The script file must call (use) the function IsAcuteTriangle to determine the type of triangle. No credit will be given if this is done any other way. • The script file must load and use a text file named Triangle.txt with data formatted as specified above. Helpful hints • Remember to suppress output in both the function & script files. • Create your own Triangles.txt file test your code.

here are my codes. I don't know what wrong but it doesn't work

clc
clear
mat = load('Triangles.txt');
[r,c]=size(mat);
tri = mat(1,:);
b = IsAcuteTriangle(tri(1),tri(2),tri(3));
for i=(1:r)
a(i) = tri(i:i,:);
b(i) = IsAcuteTriangle(tri(i(1)),tri(i(2)),tri(i(3)));
end
if b(i)==1
fprintf('The %g %g %g triangle is acute. ',tri(i(1)),tri(i(2)),tri(i(3)));
else
fprintf('The %g %g %g triangle is obtuse. ',tri(i(1)),tri(i(2)),tri(i(3)));
end


Explanation / Answer

CODE :

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote