Cody

# Problem 381. Angle between two vectors

Solution 1976767

Submitted on 15 Oct 2019
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
u = [0.5 0.5 0];; v = [1 0 0]; angle_in_degrees = vector2angle(u,v) assert(strcmp(num2str(angle_in_degrees),'45'))

Error using * Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'. Error in vector2angle (line 2) angle_in_degrees= acos(dot(u,v)/(abs(u)*abs(v))); Error in Test1 (line 3) angle_in_degrees = vector2angle(u,v)

2   Fail
u = [0 0 1]; v = [1 0 0]; angle_in_degrees = vector2angle(u,v) assert(strcmp(num2str(angle_in_degrees),'90'))

Error using * Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'. Error in vector2angle (line 2) angle_in_degrees= acos(dot(u,v)/(abs(u)*abs(v))); Error in Test2 (line 3) angle_in_degrees = vector2angle(u,v)

3   Fail
u = [0 0.8 1]; v = [1 0.3 0]; angle_in_degrees = vector2angle(u,v) assert(strcmp(num2str(round(angle_in_degrees)),'80'))

Error using * Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'. Error in vector2angle (line 2) angle_in_degrees= acos(dot(u,v)/(abs(u)*abs(v))); Error in Test3 (line 3) angle_in_degrees = vector2angle(u,v)