zsy7758758 发表于 2012-10-31 16:12

请教一个二重积分的问题

function fun=test_sy(x,y)
      
fun = 1./( sqrt(x + y) .* (1 + x + y).^2 );

>> quad2d(@(x,y) test_sy,0,1,2,9)
??? Input argument "x" is undefined.
Error in ==> test_sy at 3
fun = 1./( sqrt(x + y) .* (1 + x + y).^2 );
Error in ==> @(x,y)test_sy

Error in ==> quad2d>tensor at 355
      Z = FUN(X,Y);NFE = NFE + 1;
Error in ==> quad2d at 169
= tensor(thetaL,thetaR,phiB,phiT);

%*************************************
如果直接用quad2d却能成功
%*************************************
>> quad2d(@(x,y) 1./( sqrt(x + y) .* (1 + x + y).^2 ),0,1,2,9)
ans =
    0.0937

%**************************************
请教各位是为什么?

zsy7758758 发表于 2012-10-31 16:40

%************************
程序做如下修改
%************************
function fun=test_sy(x,y)

fun=zeros(length(x),length(y));
for i=1:length(x)
    for j=1:length(y)
      fun(i,j) = 1./( sqrt(x(i) + y(j)) .* (1 + x(i) + y(j)).^2 );
    end
end

%******************************************
>> test_sy(,)

ans =

    0.0083    0.0059    0.0044    0.0033    0.0021    0.0014
    0.0059    0.0044    0.0033    0.0026    0.0017    0.0012
    0.0044    0.0033    0.0026    0.0021    0.0014    0.0010
    0.0033    0.0026    0.0021    0.0017    0.0012    0.0009

%*************************************************

>> quad2d(@(x,y) test_sy,0,1,2,9)
??? Input argument "x" is undefined.

Error in ==> test_sy at 3
fun=zeros(length(x),length(y));

Error in ==> @(x,y)test_sy


Error in ==> quad2d>tensor at 355
      Z = FUN(X,Y);NFE = NFE + 1;

Error in ==> quad2d at 169
= tensor(thetaL,thetaR,phiB,phiT);

%*****************************************
还是老问题~!!1

zsy7758758 发表于 2012-10-31 16:42

{:{40}:} 我是新手,不知道是为什么,求大侠指点...

ChaChing 发表于 2012-10-31 21:50

quad2d(@test_sy,0,1,2,9)
...q = quad2d(fun,a,b,c,d)...fun is a function handle...

zsy7758758 发表于 2012-11-1 15:06

ChaChing 发表于 2012-10-31 21:50 static/image/common/back.gif



>> quadl(@test_sy,0,1,2,9)

??? Input argument "y" is undefined.
Error in ==> test_sy at 3
fun = 1./( sqrt(x + y) .* (1 + x + y).^2 );
Error in ==> quadl at 70
y = feval(f,x,varargin{:}); y = y(:).';

>>

zsy7758758 发表于 2012-11-1 15:10

ChaChing 发表于 2012-10-31 21:50 static/image/common/back.gif



>> quad2d(@test_sy,0,1,2,9)
ans =
    0.0937
>>

谢谢您的答案...
页: [1]
查看完整版本: 请教一个二重积分的问题