0

if i have two columnar matrices A,B . then how can i merge both matrices into a row matrix.

         A =  {-0.157681 - 0.0140601 I, 0.987384 + 0. I, 0.0000372277 - 0.00334827 I,-0.000272331 + 0.000439789 I}  ;
         B =  {0.991357 + 0. I, -0.130103 - 0.0163991 I, -0.000272562 + 0.000624515 I, 0.0000254395 - 0.00390685 I } ;
         Matrix = ( {{A, B}} )

Which gives me output enter image description here

i want to know how to remove the brackets inside the matrix. and i also want to know whether removing of these brackets effect the matrix.? Thanks in advance

M.M Umber
  • 69
  • 7

1 Answers1

3
A = ({{-0.157681 - 0.0140601 I}, {0.987384 + 0. I}, {0.0000372277 - 
      0.00334827 I}, {-0.000272331 + 0.000439789 I}});
B = ({{0.991357 + 0. I}, {-0.130103 - 0.0163991 I}, {-0.000272562 + 
      0.000624515 I}, {0.0000254395 - 0.00390685 I}});

This is a good point to say that working with column vectors in Mathematica is more trouble than it is worth - you just don't need to do it most of the time. If your A and B were normal row vectors, then all you need is Transpose[{A,B}]. Here are ways that you can work with these column vectors to make a matrix.

Join[A, B, 2] // MatrixForm
ArrayFlatten[{{A, B}}] // MatrixForm
Transpose[Flatten /@ {A, B}] // MatrixForm
Thread[Flatten /@ {A, B}] // MatrixForm

enter image description here

And then, if you want to do it the old-timey way (this is how it feels when I have to work in Fortran)

AB = ConstantArray[0.0, {4, 2}];
For[i = 1, i <= 4, i++,
  AB[[i, 1]] = A[[i, 1]];
  AB[[i, 2]] = B[[i, 1]];
  ];
AB // MatrixForm

enter image description here

Jason B.
  • 68,381
  • 3
  • 139
  • 286