The f3
function has no return value, so no value is assigned and becomes nan
.
Add return answer
to the end of the function to assign a value.
import numpy as np
import matplotlib.pyplot asplt
def3(x0,x1):
r=2*x0**2+x1**2
an=r*np.exp(-r)
returnans# Add this line
xn = 9
x0 = np.linspace (-2,2,xn)
x1 = np.linspace (-2,2,xn)
y=np.zeros(len(x0),len(x1))))
for i0 in range (xn):
for i1 in range (xn):
y[i1, i0] = f3 (x0[i0], x1[i1])
print(x0)
print(np.round(y,1))
If you ask questions, it would be easier to get answers if you put the source code instead of the screenshot so that it is reviewable sample code.
© 2024 OneMinuteCode. All rights reserved.