So I got a homework problem like this, I googled for the solution and I found a couple ways to do it. However, my professor wants students to do it with a function, and function is extremely confusing to me. (I'm extremely new to MATLAB.)
Here's my code:
u = [x1 y1 z1];
v = [x2 y2 z2];
function y = ThetaInDegrees(x1,y1,z1,x2,y2,z2)
CosTheta = dot(u,v)/(norm(u)*norm(v));
ThetaInDegrees = acosd(CosTheta);
I saw some posts in Mathworks and the code inside this function works, but I have no idea how to make it work inside a function. Moreover, how to return an error message if one/two vector(s) is(are) not finite-dimensional?
I'd really appreciate if someone can provide a detailed explanation on how to revise my code...we don't have a MATLAB textbook in this class, the professor told us to go to the TA for all coding problems, but the TA got answers wrong every time, I'm not exaggerating. Thanks in advance.