So I'm trying to write a function that works out the area of a triangle using:
function triangle = tri_area(b,h)0.5*b*h end
However, when I call the function in the command window using
area = tri_area(2,3)
, it says 'Output argument "triangle" (and maybe others) not assigned during call to "tri_area". '
I'm not sure why this comes up. If I remove the assignment of the tri_area function to triangle, I get a 'too many output arguments' error. There's obviously something with my code that Matlab doesn't like.
Best Answer