小编Myc*_*ofD的帖子

Fortran DO循环,警告仅使用整数

我在我的Ubuntu 15.04系统上安装了gfortran.在编译Fortran代码时,DO循环仅要求获取整数参数,而不是实数值或变量.这包括循环变量和步骤表达式.为什么它也不能采取真正的价值观呢?

以下是从这里开始的程序,练习3.5的嵌套do循环部分.

        program  xytab
        implicit none
        !constructs a table of z=x/y for values of x from 1 to 2 and 
        !y from 1 to 4 in  steps of .5
        real         ::   x, y, z 
        print *, '           x           y           z'
        do  x = 1,2
            do y = 1,4,0.5
                z = x/y
                print *, x,y,z
            end do
        end  do
        end  program xytab
Run Code Online (Sandbox Code Playgroud)

编译后显示的错误是:

xytab.f95:8.4:

 do y = 1,4,0.5
    1
Warning: Deleted feature: Loop variable at (1) …
Run Code Online (Sandbox Code Playgroud)

fortran gfortran fortran90 fortran95

6
推荐指数
1
解决办法
8530
查看次数

高斯拟合python中的直方图数据:Trust Region v/s Levenberg Marquardt

我的直方图清晰地显示了两个峰.但是,当用双高斯曲线拟合它时,它只显示一个峰值.几乎跟随stackoverflow中显示的每个答案.但未能得到正确的结果.它以前是由我在Fortran的老师完成的,他有两个高峰.我在一次试验中使用leastsq了python scipy.optimize.我也应该提供我的数据吗?这是我的代码.

binss = (max(x) - min(x))/0.05 #0.05 is my bin width
n, bins, patches = plt.hist(x, binss, color = 'grey') #gives the histogram

x_a = []
for item in range(len(bins)-1):
    b = (bins[item]+bins[item+1])/2
    x_a.append(b)

x_avg = np.array(x_a)
y_real = n

def gauss(x, A, mu, sigma):
    gaus = []
    for item in range(len(x)):
        gaus.append(A*e**(-(x[item]-mu)**2./(2.*sigma**2)))
    return np.array(gaus)
A1, A2, m1, m2, sd1, sd2 = [25, 30, 0.3, 0.6, -0.9, -0.9]

#Initial guesses for leastsq
p = [A1, A2, …
Run Code Online (Sandbox Code Playgroud)

python gaussian curve-fitting python-2.7

2
推荐指数
1
解决办法
1806
查看次数