Matrices layering - two matrix layering

How I layer 2 matrices on top of each other? assume we have a A = 2x2 matri,x and B = 2 x2 matrix
A = [1 1;1 1] ,
B = [0 0 ; 0 0 ] ,
A(22) = 1 is the "start of layring":
L1 = first layer result is [1 0; 0 0 ] , means = > [B(11)+A(22) B(12); (B21) B(22)]
L2 = 2nd layer result is [ 2 1 ; 0 0 ] , means = > [L1(11)+A(21) L1(12)+A(22) ; L1(21) L1(22)]
L3 = 3d layer result is [3 1 ;1 1 ], means = > [L2(11)+A(12) L2(12) ; L2(21)+A(22) L2(22)]
L4 = and the fianl layer is [4 2 ; 2 1 , means = > [L3(11)+A(11) L3(12)+A(12) ; L3(21)+A(21) L3(22)+A(22)]

3 commentaires

Dyuman Joshi
Dyuman Joshi le 21 Mar 2023
Modifié(e) : Dyuman Joshi le 21 Mar 2023
You have done that already, you just need to use the proper indexing syntax
A = [1 1;1 1];
B = [0 0;0 0];
L1 = [B(1,1)+A(2,2) B(1,2); B(2,1) B(2,2)]
L1 = 2×2
1 0 0 0
L2 = [L1(1,1)+A(2,1) L1(1,2)+A(2,2) ; L1(2,1) L1(2,2)]
L2 = 2×2
2 1 0 0
L3 = [L2(1,1)+A(1,2) L2(1,2) ; L2(2,1)+A(2,2) L2(2,2)]
L3 = 2×2
3 1 1 0
L4 = [L3(1,1)+A(1,1) L3(1,2)+A(1,2) ; L3(2,1)+A(2,1) L3(2,2)+A(2,2)]
L4 = 2×2
4 2 2 1
Anonymous User
Anonymous User le 21 Mar 2023
Thank you , but I know I have an answer for 2x2, this is just an example, the problem in large scale. How you do a 1920x1080 matrix if element (750,750) need to be the start of layring on (1,1) ?
If I am understanding correct, you want
L1 = [B(750,750)+A(751,751) B(750,751); B(751,750) B(751,751)]
%similarly for L2, L3 and L4 as well
for starting point (750,750)

Connectez-vous pour commenter.

Réponses (0)

Catégories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by