0
我想遍歷一系列c值?我怎麼做?我試圖有一個for循環或在外面while循環:Python雙循環? while和for循環?
注:我想4℃之間,以15 120值
for c in range(4,15):
i=0
while i< nt-1: #if i<nt-1 is true, the body below will be excuted
#Update the acceleration using the following equation
x[i+1] = (-y[i]-z[i])*deltat+x[i]
#Update the velocity using the follwing equation
y[i+1] =(x[i]+a*y[i])*deltat+y[i]
#Update the displacement, using follwing equation
z[i+1] = (b+z[i]*(x[i]-c))*deltat+z[i]
#go to next time step
i=i+1
OR
c=arange(4,15,1)
for p in c:
while i< nt-1: #if i<nt-1 is true, the body below will be excuted
#Update the acceleration using the following equation
x[i+1] = (-y[i]-z[i])*deltat+x[i]
#Update the velocity using the follwing equation
y[i+1] =(x[i]+a*y[i])*deltat+y[i]
#Update the displacement, using follwing equation
z[i+1] = (b+z[i]*(x[i]-p))*deltat+z[i]
#go to next time step
i=i+1
哪些變量'X,Y,NT,'和'deltaat' – enginefree
內環只是因爲它''超過後i'不會被重置爲零運行一次NT-1'第一次。但是無論如何,''''''''''''''''''''''和'z'都會被覆蓋,所以我不確定你會得到你想要的。來自不同'c'值的結果應該如何結合? – Blckknght