在 wolfram mathematica 中查找矩阵中的第 i 行 [英] Finding i-th row in a matrix in wolfram mathematica

查看:23
本文介绍了在 wolfram mathematica 中查找矩阵中的第 i 行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在 mathematica 中将一个列矩阵和一个行矩阵相乘.但是 mathematica 将行矩阵作为列矩阵.所以乘法函数不起作用.我的代码是

I have trying to multipy a column matrix and a row matrix in mathematica. But mathematica gives row matrix as a column matrix. so multipy function doesnt work. My codes are

`Y = Inverse[S];
Print["Y=", MatrixForm[Y]];
For[i = 1, i <= n, i++,
Subscript[P, i] = MatrixForm[S[[All, i]].Y[[i]]];
Print["CarpimS=", MatrixForm[S[[All, i]]]];
Print["CarpimY=", MatrixForm[Y[[i]]]];
Print["P=", Subscript[P, i]];
];  

如果有人知道这种情况,请回答

If anyone know this situation please answer

推荐答案

这是一个写得很糟糕的问题,所以我将不得不做出一些猜测.您的代码似乎与您的问题无关,但有以下例外:S[[All, i]].Y[[i]].根据您的描述,我猜我们可以说 S 是 k × k,Y 也是.如果您的目标是通过其逆 Y 的第 i 行Dot S 的第 i 列,那么您所拥有的是很好:您将每个生成为一维向量,然后生成一个标量积.但是你说你没有得到你想要的,所以我猜你想要的是外部产品.

This is a badly written question, so I'm going to have to make some guesses. Your code does not seem relevant to your question, with this exception: S[[All, i]].Y[[i]]. Given your description, I'm guessing we can say that S is k by k and so is Y. If your goal is to Dot the i-th column of S by the i-th row of its inverse Y, then what you have is fine: you produce each as a 1-d vector, and then produce a scalar product. But you say you're not getting what you want, so I'm guessing you want the outer product instead.

mS = IdentityMatrix[5];
mS[[3, 3]] = 99;
mY = Inverse[mS];
mS[[All, 3]].mY[[3]]  (* scalar product *)
Outer[Times, mS[[All, 3]], mY[[3]]] (* outer product *)

如果我猜错了,您将不得不努力改进您的问题.

If I guessed wrong, you will have to work on improving your question.

这篇关于在 wolfram mathematica 中查找矩阵中的第 i 行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆