I'm working on my very first MATLAB assignment with no previous experience and I have to create a function called 'dotcheck', which checks whether the dot product of two column vectors can be found, and then it calculates the dot product.
I'm pretty sure I have the first part of my code correct, but I keep running into an error that says "Unrecognized function or variable 'dot'." when I try to run (for example):
in my Live Editor with my dotcheck function:
function [d1,d2] = dotcheck(u,v)
fprintf('both vectors have %i entries\n',n)
disp('the dot product is not defined')
if d1==dot(u,v), d2==dot(u,v)
fprintf('the code is correct\n')
disp('check the code!')
disp('the angle between the vectors is either acute or zero')
disp('the angle between the vectors is obtuse or 180 degrees')
disp('the angle between the vectors is 90 degrees')
For some reason, it has an issue with the line:
because it doesn't understand that I'm trying to define the variable d to be the operation dot(u,v).
I tried using "dotprod" and other functions to test it out, and it had no problems with those. I can also use the operation dot(u,v) for some u and v in the Live Editor, so I know the function is defined.
I'm not sure if my coding afterwards is correct or not (because it won't let me get past this error), so I would also appreciate thoughts on how I can fix that to display the correct dot products for each particular condition.
Any advice or help is appreciated.
Thank you so much!