Advertisement
ashishKujur

ex_9

Oct 15th, 2021
1,561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.64 KB | None | 0 0
  1. A=[1 2 3; 2 2 2; -1 2 1];
  2. B=[1 0 0; 1 1 0; 1 1 1];
  3. C=[1 1; 2 1; 1 2];
  4.  
  5. % Part (a)
  6. A+B
  7. A*B
  8. A+C %error because dimensions of A and C do not match
  9. B*A
  10. B-A
  11. A*C
  12. C-B %error because of dimension of C and B do not match
  13. C*A %error because C and A are incompatible for matrix multiplication
  14.  
  15. %Part (b)
  16. %{
  17. The difference between A*B and A.*B is that A*B is the usual
  18. matrix multiplication and on the other hand, A.*B is element
  19. wise matrix multiplication.
  20. It is possible to compute A*B if number of columns of A = number of rows of B.
  21. On the other hand, it is possible to compute A.*B if the dimensions of A and B are the same.
  22. %}
  23. A.*B
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement