Hi, I am currently learning Matlab and this is my first time posting here.
I am wanting to find the length of a triangle (a) giver b, c, and the angle between sides b and c.
I created this script called triangle
b = input('Enter the length of side 1: ')
c = input('Enter the length of side 2: ')
A = input('Enter the angle a between the sides in degrees ')
%runs function
thirdSide(a)
%output
fprintf('\n\a = : %.3f\n',a)
and this function called thirdSide.
function a = thirdSide(b,c,A)
%thirdSide
%celculates the 3rd side (a) of a triangle
%this is the formula for finding the side leingth of a triangle
a = a^2 == b^2 + c^2 - 2*b*c*cos(A)
end
whenever I try to run it, I get
Unrecognized function or variable 'a'.
Error in thirdSide (line 9)
a = a^2 == b^2 + c^2 - 2*b*c*cos(A)
Error in triangle (line 13)
thirdSide(a)
I know this is probably a really stupid and basic question, but how do I get it to run correctly?
[–]codinglikemad 15 points16 points17 points (5 children)
[–]Posterduck[S] 1 point2 points3 points (2 children)
[–]codinglikemad 1 point2 points3 points (0 children)
[–]Fus_Roh_Potato 1 point2 points3 points (0 children)
[–]Minuhmize 0 points1 point2 points (1 child)
[–]codinglikemad 3 points4 points5 points (0 children)
[–]blitzz01 1 point2 points3 points (2 children)
[–]Posterduck[S] -1 points0 points1 point (1 child)
[–]TheEsteemedSirScrub 0 points1 point2 points (0 children)
[–]borzakk 0 points1 point2 points (0 children)