The problem is to insert a column into the second column position in a 2D matrix.
Mathematica
mat = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; mat = Insert[Transpose[mat], {90, 91, 92}, 2]; mat = Transpose[mat]
|
{{1,90,2,3}, {4,91,5,6}, {7,92,8,9}} |
Matlab
Fortran
Maple
Python
import numpy as np mat=np.array([[1,2,3], [4,5,6], [7,8,9]]) mat=numpy.insert(mat,1,[90,91,92],1)
|
array([[ 1, 90, 2, 3], [ 4, 91, 5, 6], [ 7, 92, 8, 9]]) |