Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.65 KB | None | 0 0
  1. %Solution1.m
  2. E =eye(3)
  3. u = E(:,1)
  4. E(3,1) = 5
  5. v = E*u
  6. A = ones(3) + eye(3)
  7. b = A(:,3)
  8. C = inv (A)
  9.  
  10. x = A\b
  11. x = C*b
  12.  
  13. %This is a comment
  14. %help slsh
  15. %last line was a comment
  16. help slash
  17. %"help slash" last line was ignored :O
  18. %but it works in the console
  19. %Edit : it works! I actually forgot to save the file :p
  20.  
  21. u = [2 4 5]
  22. v = [2;4;5]
  23. v = [2 4 5]'
  24. w= 2:5
  25. u= 1:2:7
  26. A = [1 2 3; 4 5 6]
  27. A = [1 2 3
  28. 4 5 6]
  29. %both last two commands work as expected >.>
  30. B = [1 2 3; 4 5 6]'
  31. %created [1 2 3; 4 5 6] first, transposed it and put it into B
  32. diag(v)
  33. disp("toeplitz(v):")
  34. toeplitz(v)
  35. disp("toeplitz(w):")
  36. toeplitz(w)
  37. disp("toeplitz(w,v):")
  38. toeplitz(w,v)
  39. disp("ones(5)")
  40. ones(5)
  41. zeros(7)
  42. eye(10)
  43. rand(5)
  44. randn(5)
  45. disp("ones (4,7)")
  46. ones(4,7)
  47. disp("size(A):")
  48. size(A)
  49. %probably next command shall make ones with 2 rows and 3 collumns
  50. disp("ones size(A):")
  51. ones (size(A))
  52.  
  53. %it did!
  54. zeros(size(A))
  55. %will next command excecute? A is 2x3
  56. eye(size(A))
  57. %IT DID!
  58. A(3,2) = 7
  59. %A NEW ROW IS CREATED!
  60.  %  --> A(3,:) = w
  61.  %Error occured since w is 1 X 4
  62.  A(3,:) = v
  63.  
  64. % A(:,2) = w error occured since w is 1X4 but col 2 of A has 3 elements
  65. A([2 3],:) = A([3 2], :)
  66.  
  67. A(2,2)
  68. A(1,:)
  69. A(:,3)
  70. A(1:3,2:3)
  71. A(:)
  72. triu(A)
  73. tril(A)
  74. disp("B:")
  75. B
  76. A*B
  77. %A.*B is not possible because A is 3x3 where B is 3x2
  78. A.*A'
  79. inv (A)
  80. pinv(A)
  81. A\v
  82. inv(A)*v
  83. det(A)
  84. rank(A)
  85. size(A)
  86. trace(A)
  87. null(A)
  88. orth(A)
  89.  
  90.  
  91. E = eye(4)
  92. E(2,1) = -3
  93. E*(ones(4))
  94.  
  95. [L,U,P] = lu(A)
  96. e = eig(A)
  97. [S,E] = eig(A)
  98. [Q,R] = qr(A)
  99.  
  100. plot(v)
  101. x= A(:,2)
  102. y = L(:,1)
  103. disp("plot");
  104. plot(x,y)
  105. disp("plot red +");
  106. plot (x,y,'r+:')
  107. disp("plot --");
  108. plot (x,y,'--')
  109. plot(x,y,'o')
  110. loglog(x,y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement