jeudi 21 mars 2019

I am unsure how to plot my values for my variables A and T at the point where y0 <= zero

I have the following code:

u0 = 18
l = 0.3
n = 3
m = 1000
dt = 0.1
t = np.arange(0, 100, 0.1)

u = np.zeros((n, m))

def u1(A, t, T):
    return u0 + A/2 * np.sin((2 * np.pi * t)/T)

for A in range(29):
    for T in range(1, 30):
        for j in range(m):
            u[0][j] = u1(A, dt*j, T)
.
.
.

for i in range(0, n):    
    for j in range(m-1):
        u[i][j+1] = u[i][j] + dt * l * (x[i-1][j] - x[i][j]) * (u[i-1][j] - u[i][j])
        y0 = l * (x[i-1][j] - x[i][j])
        if y0 <= 0:
            plt.scatter(T, A)
            plt.show()

There is more code in between this but it is not relevant for the problem I have.

So this code is plotting ALL the values of A and T when y0 <= 0 but I want it to plot ONLY the values of A and T at the point when y0 <= 0 and I don't know how to do this. I have tried using the np.where method but this does the same thing. Any help would be appreciated.

Aucun commentaire:

Enregistrer un commentaire