Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Question 1
- % Put your work here
- v1 = [0.4082;0.8165;-0.4082];
- u1 = [0.5875;0.1073;0.8022];
- dotvu = dot(v1,u1)
- if dotvu == 0
- q1_result = true
- else
- q1_result = false
- end
- %% Question 2
- % Put your work here
- v2 = [1;1;1;1;0;0];
- u2 = [5;5;5;5;5;5];
- q2_result = (dot(v2,u2)*u2)/(norm(u2)^2)
- %% Question 3
- % Put your work here
- v3 = u2;
- V1 = v2;
- V2 = [1;-1;0;0;1;0];
- V3 = [0;-1;1;0;-1;1];
- V4 = [0;-1;0;1;-1;-2];
- V = [V1 V2 V3 V4];
- proj_set = [];
- for i = 1:4
- num = dot(v3,V(:,i))*V(:,i);
- proj = num/(norm(V(:,i))^2);
- proj_set = [proj_set, proj];
- end
- q3_result = proj_set(:,1) + proj_set(:,2) + proj_set(:,3) + proj_set(:,4)
- %% Question 4
- % Put your work here
- % See below \/
- %% Question 5a
- % Put your work here
- p5a = [0 1 0 1];
- q5a = [1 0 -1 1];
- q5a_result = mypolyinnerproduct(p5a,q5a)
- %% Question 5b
- % Put your work here
- p5b = [1 2 -4];
- q5b_result = sqrt(mypolyinnerproduct(p5b,p5b))
- %% Question 5c
- % Put your work here
- p5c = [1 0 0 -5];
- q5c_result = p5c/sqrt(mypolyinnerproduct(p5c,p5c))
- %% Question 6
- % Put your work here
- f = [1 -2 0 0];
- g = [0 0 1 0];
- dotfg = mypolyinnerproduct(f,g);
- q6_result = (dotfg*g)/mypolyinnerproduct(g,g)
- %% Question 4 Function
- function output4 = mypolyinnerproduct(p,q)
- P4 = polyint(conv(p,q));
- output4 = polyval(P4,1)-polyval(P4,-1);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement