Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. %% Question 1
  2. % Put your work here
  3.  
  4. v1 = [0.4082;0.8165;-0.4082];
  5. u1 = [0.5875;0.1073;0.8022];
  6. dotvu = dot(v1,u1)
  7.  
  8. if dotvu == 0
  9. q1_result = true
  10. else
  11. q1_result = false
  12. end
  13.  
  14. %% Question 2
  15. % Put your work here
  16.  
  17. v2 = [1;1;1;1;0;0];
  18. u2 = [5;5;5;5;5;5];
  19.  
  20. q2_result = (dot(v2,u2)*u2)/(norm(u2)^2)
  21.  
  22. %% Question 3
  23. % Put your work here
  24.  
  25. v3 = u2;
  26. V1 = v2;
  27. V2 = [1;-1;0;0;1;0];
  28. V3 = [0;-1;1;0;-1;1];
  29. V4 = [0;-1;0;1;-1;-2];
  30. V = [V1 V2 V3 V4];
  31.  
  32. proj_set = [];
  33. for i = 1:4
  34. num = dot(v3,V(:,i))*V(:,i);
  35. proj = num/(norm(V(:,i))^2);
  36. proj_set = [proj_set, proj];
  37. end
  38.  
  39. q3_result = proj_set(:,1) + proj_set(:,2) + proj_set(:,3) + proj_set(:,4)
  40.  
  41. %% Question 4
  42. % Put your work here
  43.  
  44. % See below \/
  45.  
  46. %% Question 5a
  47. % Put your work here
  48.  
  49. p5a = [0 1 0 1];
  50. q5a = [1 0 -1 1];
  51.  
  52. q5a_result = mypolyinnerproduct(p5a,q5a)
  53.  
  54. %% Question 5b
  55. % Put your work here
  56.  
  57. p5b = [1 2 -4];
  58. q5b_result = sqrt(mypolyinnerproduct(p5b,p5b))
  59.  
  60. %% Question 5c
  61. % Put your work here
  62.  
  63. p5c = [1 0 0 -5];
  64.  
  65. q5c_result = p5c/sqrt(mypolyinnerproduct(p5c,p5c))
  66.  
  67. %% Question 6
  68. % Put your work here
  69.  
  70. f = [1 -2 0 0];
  71. g = [0 0 1 0];
  72. dotfg = mypolyinnerproduct(f,g);
  73. q6_result = (dotfg*g)/mypolyinnerproduct(g,g)
  74.  
  75.  
  76. %% Question 4 Function
  77.  
  78. function output4 = mypolyinnerproduct(p,q)
  79. P4 = polyint(conv(p,q));
  80. output4 = polyval(P4,1)-polyval(P4,-1);
  81. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement