This first lines work, and i get V(i) =V+QIN(i)-QOUT(i), but when i try to do
T(i) = (T + C(i) + TIN(i)*QIN(i)) /((C(i)+QIN(i)), how can I loop trought each C [i],
QOUT=[1.0, 3.0, 1.0, 2.0]
QIN=[2.0, 3.0, 5.0, 2.0]
TIN=[10.0,12.0,13.0, 12.0]
V=[2.0, 4.0, 5.0]
T=[10.0, 11.0, 12.0]
#4 iterations
#V(i) = V+QIN(i)-QOUT(i)
lineNum=0
for line in range(len(QIN)):
C = []
for i in range(len(V)):
C.append(V[i]+QIN[line]-QOUT[lineNum])
lineNum +=1
print C
lineNum=0
for t1 in range(len(TIN)):
Tx=[]
for c in range(len(C)):
for i in range(len(T)):
Tx.append((T[i]*C[c]+TIN[t1]*QIN[lineNum])/(C[c]+QIN[lineNum]))
lineNum +=1
print Tx
Sorry could not post images.
indentation problems are on lines 19,21,23,25,29 – switch special characters on in any editor and you will see them.
But real cause of problem is in reusing numlines variable, thus it rises IndexError.
Possible solution:
I assumed you really intended to use linenum in this context…
PS: for t1 in range(len(TIN)):… part need unfolding to, but I don’t have spirit for this right now