0

我正在尝试解决双重积分,其中我正在使用 quadgk 函数解决内部积分和外部积分。

% The integrand is of course a function of both x and y
integrand = @(x,y) (phi(j,y,X) - phi(j,x,X))*(phi(i,y,X) - phi(i,x,X))/abs(y-x)^(2*s+1)

% The inner integral is a function of x, and integrates over y
inner = @(x) quadgk(@(y)integrand(x,y), x-lambda, x+lambda)

% The inner integral is integrated over x to yield the value of the double integral 
dblIntegral = quadgk(inner, -(1+lambda), 1+lambda)

我收到以下错误:

integrand = @(x,y)(phi(j,y,X)-phi(j,x,X))*(phi(i,y,X)-phi(i,x,X))/abs(y-x)^(2*s+1)
inner = @(x)quadgk(@(y)integrand(x,y),x-lambda,x+lambda)

??? Error using ==> quadgk at 108
A and B must be scalar floats.

Error in ==> @(x)quadgk(@(y)integrand(x,y),x-lambda,x+lambda)
Error in ==> quadgk>evalFun at 344
        fx = FUN(x);

Error in ==> quadgk>f1 at 362
    [y,too_close] = evalFun(tt);

Error in ==> quadgk>vadapt at 258
        [fx,too_close] = f(x);

Error in ==> quadgk at 197
[q,errbnd] = vadapt(@f1,interval);

Error in ==> frational_laplacian at 29
dblIntegral = quadgk(inner, -(1+lambda), 1+lambda)
4

1 回答 1

0

您遇到了这个问题,因为在内部quadgk使用值向量评估传递的函数。这意味着在行

dblIntegral = quadgk(inner, -(1+lambda), 1+lambda)

该函数inner被调用,x 是一个向量。quadgk要求 a 和 b(在本例中为 x±lambda)是标量,因此您会得到您一直看到的错误。如果要确保inner始终获取标量作为输入,可以使用

dblIntegral = quadgk(@(x)arrayfun(inner,x), -(1+lambda), 1+lambda)
于 2013-10-22T08:54:14.730 回答