I need to code a mathematical function that will use different value at specific x position. (It would represent light passing through different medium)
I tried to make a very simple code first to see if it would work, and unfortunately I can't seem to properly input it as I get no graph.
def function(x):
if x < 10:
a = 1
if (10.0 <= x <= 20.0):
a = 0.5
if x > 20:
a = -1
return x*a
x = np.arange (0,30,90)
y = function(x)
plt.plot(x,y,'b')
plt.show()
Thanks
Aucun commentaire:
Enregistrer un commentaire