入門小菜鳥的學(xué)習(xí)筆記,希望大佬們幫忙糾錯啦~侵權(quán)立刪。?
解法一:
import numpy as np
x = np.array([[1,2,3],[4,5,6],[7,8,9]])
y = np.array([[1,2,1],[2,1,1],[1,1,2]])
R = np.multiply(x,y)
print("x=\n",x)
print("y=\n",y)
print("矩陣對應(yīng)元素相乘的結(jié)果為:\n",R)
運行結(jié)果:
解法二:
import numpy as np
mat1 = np.mat([[1,2,3],[2,3,4],[4,5,6]])
mat2 = np.mat([[1,2,3],[2,1,4],[4,1,6]])
mat3 = np.mat([[0,0,0],[0,0,0],[0,0,0]])
for i in range(3):
for j in range(3):
mat3[i,j] = mat1[i,j]*mat2[i,j]
mat3
?運行結(jié)果:
文章來源:http://www.zghlxwxcb.cn/news/detail-610054.html
個人學(xué)習(xí)筆記,僅供參考,如有錯誤,請多指正。?文章來源地址http://www.zghlxwxcb.cn/news/detail-610054.html
到了這里,關(guān)于學(xué)習(xí)筆記:兩個3*3的矩陣,實現(xiàn)其對應(yīng)位置的數(shù)相乘,返回一個新的矩陣的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!