Matrix mathematica中的矩阵和
我想对之前计算的矩阵求和。 r=1时,n=3;下标[P,i]是3x3矩阵,如P1、P2、P3。 我的代码如下:Matrix mathematica中的矩阵和,matrix,sum,wolfram-mathematica,Matrix,Sum,Wolfram Mathematica,我想对之前计算的矩阵求和。 r=1时,n=3;下标[P,i]是3x3矩阵,如P1、P2、P3。 我的代码如下: 'Y = Inverse[S]; Print["Y=", MatrixForm[Y]]; For[i = 1, i <= n, i++, Subscript[P, i] = MatrixForm[Outer[Times, S[[All, i]], Y[[i]]]]; Print["CarpimS=", MatrixForm[S[[All, i]]]]; Print[
'Y = Inverse[S];
Print["Y=", MatrixForm[Y]];
For[i = 1, i <= n, i++,
Subscript[P, i] = MatrixForm[Outer[Times, S[[All, i]], Y[[i]]]];
Print["CarpimS=", MatrixForm[S[[All, i]]]];
Print["CarpimY=", MatrixForm[Y[[i]]]];
Print["P=", MatrixForm[Outer[Times, S[[All, i]], Y[[i]]]]];
];
toplamP = MatrixForm[ConstantArray[0, {n, n}]];
For[i = 2. r + 1, i <= n, i++,
toplamP = toplamP + Subscript[P, i];
];
Print["ToplamP=", toplamP];'
但是mathematica只给了我P3,P3没有矩阵形式。请看我在这里对矩阵形式的评论。你的下标[P,i]不是一个矩阵,它是一个以输出格式包装的矩阵。非常感谢你,我解决了这个问题。