0
from pylab import *
###FUNCTIONS##
def LOSS(y0,y1):
return sum(abs(y0-y1))
def genuchten(t,C,k):
return 1/(1+(C/t)**k)**(1-1/k)
###MAIN#######
if __name__ == '__main__':
t0 = linspace(0,10,100)
f0 = genuchten(t0,3,3)
x = linspace(1,10,10)
y = linspace(1,10,10)
X,Y = meshgrid(x,y)
Z = zeros(shape(X))
for i in range(len(x)):
for j in range(len(y)):
f = genuchten(t0,X[i][j],Y[i][j])
Z[i][j] = LOSS(f0,f)
contourf(X,Y,Z)
show()
這工作,但我覺得必須有一個更直接的方式。看來MATLAB有一個ARRAYFUN函數可以自動完成這個功能嗎?
我將在'ogrid'和'ravel'讀了,我會回來的。這看起來像一個非常複雜的解決方案 – RodericDay 2012-08-09 17:44:08