I have two matrices
fi = [[f1], Nij = [[N11 N12 .......N1n],
[f2], [N21 N22 .......N2n],
. ...
. ...
[fn]] [Nn1 Nn2 .......Nnn]]
I want to multiply:
f1 to each element of the 1st row,
f2 to each element of the 2nd row,
and so on.
I.e. I want Xij = fi*Nij
where fi is a column matrix and Xij & Nij is nxn matrix.
I tried using
import numpy as np
fi = np.linspace(1,5, num =5)
fi = np.asmatrix(fi)
def Xij(ai):
Nij = np.ones((5,5))
for i in range(len(fi)):
for j in range(len(fi)):
Xij[i,j] = ai[i] * Nij[i,j]
return Xij
Zij = Xij(fi)
It gives me this error TypeError: 'function' object does not support item assignment
Why? and how do I solve this?