How can I construct a mathematical expression of two variables in python?

I have a function for changing time and depth, simplified to:

def f(z,t): return np.exp(-z)*np.sin(tz) z = np.linspace(0,3000,num=3001) t = np.arange(0,40000,4000) 

I want to build the result for all z at each time step in t, which will lead to something like this:

enter image description here

but I don’t know how to do it. I am sure this is very simple, but I'm not used to doing this in python.

+4
source share
1 answer
 import matplotlib.pyplot as plt import numpy as np def f(z,t): return np.exp(-z)*np.sin(tz) z = np.linspace(0,5,3001) t = np.arange(0,40000,4000) for tval in t: plt.plot(z, f(z, tval)) plt.show() 

enter image description here

+8
source

All Articles