I have two 9×9 matrices, A and B.
I would like to create a large matrix C with the following pattern
A B B B B B
B A B B B B
B B A B B B
B B B A B B
B B B B A B
B B B B B A
As you can see, the A matrices are on the diagonal, the B are everywhere else. I’m trying to create a code so that this pattern continues no matter how great the dimensions are.
E.g. 10 matrices x 10 matrices still has matrix A along the diagonal and B’s everywhere else.
Best to use horzcat and vertcat or something else like blkdiag? I’d rather not convert these matrices to cells as matrix A and B already contain information.
Thank you everyone for taking the time to read.
How about (refined)
Following on from the entirely valid comments below, I added the ‘mask’ to ensure that the correct pieces are selected from C.