I am unable to get the correct value for the conditional if statement
nested with for loop
.Here is an example written in code,
# Input data
d11 = np.matrix([[3,6,1],[6,8,1],[1,1,1],[5,8,9]])
qp1 = np.matrix([[1],[3],[5]])
h1 = np.matrix([[5],[40],[100],[5]])
I need that row of d11 matrix
whose value on multiplying with qp1 is less than the corresponding value in h1 i.e d11[i] * qp < h[i].The code for this is,
for x in range(len(d11)):
if d11[x] * qp1 < h1[x]:
a = d11[x]
else:
a = []
when we multipy d11 and qp1 we get the values as [26,35 , 9 ,22]
.Thus if we compare with h1, we find the condition is True for 2nd row i.e 35< 40
and 3rd row i.e9 < 100
.So the answer is [[6,8,1],[1,1,1]]
.But i am unable to get the answer.Please suggest me the correct way..