For example I have this matrix(3x3) and I want to make a new 2x2 matrix with the max values from all the submatrixes :
= [
5 4 6
3 2 3
8 8 9
first submatrix:
[5 4
3 2 ]
max value=5
second submatrix:
[4 6
2 3]
max value=6
third submatrix:
[3 2
8 8 ]
max value=8
fourth submatrix:
[2 3
8 9]
max value=9
and I want to get this matrix(2x2) that has all the max values as elements of the previous submatrixes:
NewA=[5 6
8 9]
One last thing the only thing you can use are basic things like for loops if statements....(simple solutions,begginer solutions) Also you can't use the max function,you have to write the code for that,and the solution should work for every square matrix
Since the sub-matrices are
2x2
you can manually compute the max:or
If
A
is a square matrix both methods can be written more compact as: