Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.65 KB | None | 0 0
  1. %Sol2
  2. %----- Q1 -----
  3.  
  4. A = [2 3; 4 5]
  5. x = [1; -7]
  6. b = [24; 5]
  7. if A*x == b
  8.     display("Ax equals b");
  9. else display ("Ax is not equal to b");
  10. end
  11.  
  12. %----- Q2 -----
  13. A = eye(3)
  14. v = [3:5]'
  15. A*v
  16. %A*v = v
  17. v'*v
  18. %dot product of v and v which is 50
  19. %41833
  20. % v*A creates problem because v is 3X1 where A is 3x3; so multiplication is not possible
  21.  
  22.  
  23. %----- Q3 -----
  24. A = ones(4)
  25. v = ones(4,1)
  26. disp("A*v is: ")
  27. A*v
  28. B = eye(4) + ones(4)
  29. w = zeros(4,1) + 2*ones(4,1)
  30. disp("B*w =")
  31. B*w
  32.  
  33.  
  34. %----- Q4 -----
  35. P = pascal(4)
  36. inv(P)
  37.  
  38. %----- Q5 -----
  39. L = abs(pascal(4,1))
  40. if P == L*L'
  41.     disp("P equals LL'")
  42. else disp("P is not equal to LL'")
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement