Lab1 Ex5
You cannot submit for this problem because the homework's deadline is due.
Ex5. Simple linear algebra (15 marks)
(* Update: For this problem, the submitted file should be named ex5.m
.*)
Get two square matrices \(A\) and \(B\) of the same size from user input. Output the following in the given order:
Their element-wise sum \(A+B\).
Their element-wise product of \(A\) and \(B\), i.e. \(C\) where \(c_{ij}=a_{ij}\cdot b_{ij}\).
Their matrix product \(AB\).
\(C\) where \(c_{ij} = 2 a_{ij}\).
The element-wise square of \(A\), i.e. \(C\) where \(c_{ij} = a_{ij}^2\).
The (matrix) product of \(B\) with itself, i.e. \(B^2\).
Their horizontal concatenation, i.e., put \(A\) on the left and \(B\) on the right, side by side, to form a new matrix.
Their vertical concatenation, i.e., put \(A\) on top of \(B\), side by side, to form a new matrix.
Sample Test Case
Input:
[3,6,2.2;1,4.5,10;7,7.1,0]
[5,1.3,2.9;1,4,-6;-2.9,8,4]
Output:
8.0000 7.3000 5.1000
2.0000 8.5000 4.0000
4.1000 15.1000 4.0000
15.0000 7.8000 6.3800
1.0000 18.0000 -60.0000
-20.3000 56.8000 0
14.6200 45.5000 -18.5000
-19.5000 99.3000 15.9000
42.1000 37.5000 -22.3000
6.0000 12.0000 4.4000
2.0000 9.0000 20.0000
14.0000 14.2000 0
9.0000 36.0000 4.8400
1.0000 20.2500 100.0000
49.0000 50.4100 0
17.8900 34.9000 18.3000
26.4000 -30.7000 -45.1000
-18.1000 60.2300 -40.4100
3.0000 6.0000 2.2000 5.0000 1.3000 2.9000
1.0000 4.5000 10.0000 1.0000 4.0000 -6.0000
7.0000 7.1000 0 -2.9000 8.0000 4.0000
3.0000 6.0000 2.2000
1.0000 4.5000 10.0000
7.0000 7.1000 0
5.0000 1.3000 2.9000
1.0000 4.0000 -6.0000
-2.9000 8.0000 4.0000
Lab1 Exercises
- Status
- Finished
- Problems
- 5
- Open Since
- 2021-05-20 18:15
- DDL
- 2021-05-22 22:00
- Extension
- 150.0 hour(s)