在Matlab中非常简单,但我无法在Python中获得它.如何获得以下内容:
x=np.array([1,2,3])
y=np.array([4,5,6,7])
z=x.T*y
z=
[[4,5,6,7],
[8,10,12,14],
[12,15,18,21]]
Run Code Online (Sandbox Code Playgroud)
如在
x [4][5][6][7]
[1]
[2]
[3]
Run Code Online (Sandbox Code Playgroud)
在科学蟒蛇,这将是一个外部产品 np.outer(x,y)
请参阅http://docs.scipy.org/doc/numpy/reference/generated/numpy.outer.html:
import numpy;
>>> x=numpy.array([1,2,3])
>>> y=numpy.array([4,5,6,7])
>>> numpy.outer(x,y)
array([[ 4, 5, 6, 7],
[ 8, 10, 12, 14],
[12, 15, 18, 21]])
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
95 次 |
| 最近记录: |