声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1484|回复: 5

[编程技巧] 请教一个二重积分的问题

[复制链接]
发表于 2012-10-31 16:12 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
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
[Qsub,esub] = tensor(thetaL,thetaR,phiB,phiT);

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

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

本帖被以下淘专辑推荐:

回复
分享到:

使用道具 举报

 楼主| 发表于 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([0 1 2 3 ],[6 7 8 9 11 13])

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
[Qsub,esub] = tensor(thetaL,thetaR,phiB,phiT);

%*****************************************
还是老问题~!!1
 楼主| 发表于 2012-10-31 16:42 | 显示全部楼层
我是新手,不知道是为什么,求大侠指点...
发表于 2012-10-31 21:50 | 显示全部楼层
  1. quad2d(@test_sy,0,1,2,9)
复制代码

...q = quad2d(fun,a,b,c,d)...fun is a function handle...

 楼主| 发表于 2012-11-1 15:06 | 显示全部楼层


>> 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(:).';

>>
 楼主| 发表于 2012-11-1 15:10 | 显示全部楼层


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

谢谢您的答案...
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-21 02:37 , Processed in 0.076130 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表