Home > front end >  How to create a matrix from a quarter matrix using symmetry
How to create a matrix from a quarter matrix using symmetry

Time:10-20

As an instance I have a matrix like this:

A = [1 2;
     3 4]

The matrix A is the quarter of a matrix, the full matrix B can be obtained by mirroring A on the vertical and horizontal mirror axes. The resullt should be:

B =     [1 2 2 1;
         3 4 4 3;
         3 4 4 3;
         1 2 2 1]

How can I achive this in Matlab?

Edit: Is there a better way than

Q = [A fliplr(A)]
B = [Q ; flip(Q)]

?

CodePudding user response:

You could do it in a single line, although "better" is slightly subjective

B = [A, fliplr(A); flipud(A), rot90(A,2)]
  • Related