由买买提看人间百态

topics

全部话题 - 话题: dblquad
(共0页)
r****a
发帖数: 3249
1
来自主题: Computation版 - Matlab中dblquad作积分时出现的问题
我在做下面那个积分时老是告诉我“??? Attempted to access y(1); index out of
bounds because numel(y)=0.”,请各位老大帮我看看我什么地方搞错了,式中除积分
变量z,r外都是赋有初值的变量。
p1=dblquad(@(z,r) ((z-(y-q/cos(theta)+r*sin(theta))/thegema)/omegaC)^(1.5)*
thegema*exp(-0.5*(z/thegemaS)^2)/((2*pi)^0.5*thegemaS), (y-q/cos(theta)+r*
sin(theta))/thegema,(y-q/cos(theta)+r*sin(theta))/thegema+omegaC,-0.5/
thegema,0.5/thegema,1e-12);
先谢了!
g****y
发帖数: 199
2
来自主题: Computation版 - Matlab中dblquad作积分时出现的问题
try
y = 1;
theta = 0.5;
r= 2;
q =3;
thegemaS = 4;
thegema = 3;
omegaC=1;
dblquad(@(z,r) (((z-(y-q./cos(theta)+r.*sin(theta))./thegema)./omegaC).^(1.5
).*...
thegema.*exp(-0.5.*(z./thegemaS).^2)/((2*pi).^0.5.*thegemaS)), (y-q./cos(
theta)+r.*...
sin(theta))./thegema,(y-q./cos(theta)+r.*sin(theta))./thegema+omegaC,-0.5./.
..
thegema,0.5./thegema,1e-12)
answer is: 0.0773
my matlab version is R2007b
g****y
发帖数: 199
3
来自主题: Computation版 - Matlab中dblquad作积分时出现的问题
hehe... 搞错了,不好意思,呵呵。你的r既是函数变量又是上限?dblquad是求定积分
的,要给定上下限。
a*******x
发帖数: 47
4
来自主题: Computation版 - 计算中这样的bug!

Here if I use the inline('..', 'x','y', ...) then the results
are identical.
dblquad(inline('0.5/pi *cos(x).^3.*cos(y).^4 .* (sin(x).^2.*cos(y).^2+sin(y).^2)','x','y'), ...
-pi/2,pi/2,-pi/2,pi/2)
dblquad(inline('0.5/pi *cos(x).^3.*cos(p).^4 .* (sin(x).^2.*cos(p).^2+sin(p).^2)','x','p'),...
-pi/2,pi/2,-pi/2,pi/2)
results:
ans =
0.08333308868666
ans =
0.08333308868666
Use your codes but without the '**2' at the end,
dblquad('0.5/pi *cos(x).^3.*cos(y).^4 .* (sin(x).^2.*cos(y).^2+sin(y).^2
t***h
发帖数: 5601
5
来自主题: Computation版 - 计算中这样的bug!
don't know why the second is different, though small.
EDU» format long
EDU» warning off
EDU» dblquad(inline('0.5/pi *cos(x).^3.*cos(y).^4 .*
(sin(x).^2.*cos(y).^2+sin(y).^2)'),-pi/2,pi/2,-pi/2,pi/2)*2*3
ans =
0.50000020278506
EDU» dblquad(inline('0.5/pi *cos(x).^3.*cos(p).^4 .*
(sin(x).^2.*cos(p).^2+sin(p).^2)'),-pi/2,pi/2,-pi/2,pi/2)*2*3
ans =
0.50000057060518
EDU» dblquad(inline('0.5/pi *cos(p).^3.*cos(y).^4 .*
(sin(p).^2.*cos(y).^2+sin(y).^2)'),-pi/2,pi/
g***i
发帖数: 90
6
来自主题: Computation版 - 计算中这样的bug!
大家不妨copy下面两行matlab语句到matlab6.0分别执行一下,
看结果是否相同
dblquad('0.5/pi *cos(x).^3.*cos(y).^4 .* (sin(x).^2.*cos(y).^2+sin(y).^2)',
-pi/2,pi/2,-pi/2,pi/2)*2*3
dblquad('0.5/pi *cos(x).^3.*cos(p).^4 .* (sin(x).^2.*cos(p).^2+sin(p).^2)',
-pi/2,pi/2,-pi/2,pi/2)*2*3
然后看看这两行语句究竟有什么不同?
难道是我的系统有问题?
这么个古怪的bug害惨我了
你也可以试着用函数,呵呵,又有新的bug来了
a*******x
发帖数: 47
7
来自主题: Computation版 - 计算中这样的bug!

I have tried your code, the results are different, but still within the error
tolerence of dblquad, which is 1E-6 by default.
If you want identical results, you can either use functions or write as :
dblquad(inline('...', 'x','y/p',), ...)
to specify explicitly the arguments. Otherwise matlab have to decide itself,
which might cause some difference, but still within the error tolerence.
a*******x
发帖数: 47
8
来自主题: Computation版 - 计算中这样的bug!
My code gives an answer of about 1/12, since I had removed the *3*2 at
the end of the inline function, I don't think there is anything wrong.
dblquad(inline('0.5/pi *cos(x).^3.*cos(y).^4 .* (sin(x).^2.*cos(y).^2+sin(y).^2) *2*3','x','y'), ...
-pi/2,pi/2,-pi/2,pi/2)
ans =
0.50000008957241
dblquad(inline('0.5/pi *cos(x).^3.*cos(p).^4 .* (sin(x).^2.*cos(p).^2+sin(p).^2) *2*3','x','p'), ...
-pi/2,pi/2,-pi/2,pi/2)
ans =
0.50000008957241
h******g
发帖数: 11250
9
来自主题: PhotoGear版 - 问獭灵童或其他matlab大牛
怎么积?
你的意思是
y=1:1:10000000
求F(x0*y)
然后再积分?
用dblquad不行
v***a
发帖数: 23651
10
来自主题: PhotoGear版 - 问獭灵童或其他matlab大牛
我想知道dblquad有什么局限性?
h******g
发帖数: 11250
11
来自主题: PhotoGear版 - 问獭灵童或其他matlab大牛
dblquad(F, x0, x0, y1, y2)=0
c*******e
发帖数: 8624
12
来自主题: Computation版 - 问个matlab二重数值积分的问题
kernal比如是f(x,y),x=x1(y) to x2(y), y=y1 to y2
我对matlab积分的函数不是很熟悉
首先是不是不能用dblquad,那样好象x也要求是定限?
我就想用int先积x部分,但是问题是int是符号积分
f(x,y)现在找不到这么一个解(等了很久也没结果)
平时我都自己写,4重的积分我也用Gaussian Quadrature
写过,但是效率好象很差,用的都是for loop,因为
这样的积分我要用很多次(在循环里面),是不是用
matlab本身的函数要效率好很多?
应该是很容易的问题,搞了1个多小时没搞出来,哪位帮忙看看吧.
r****a
发帖数: 3249
13
来自主题: Computation版 - Matlab中dblquad作积分时出现的问题
多谢明月清风,未名的高人啊

.5
r****a
发帖数: 3249
14
来自主题: Computation版 - Matlab中dblquad作积分时出现的问题
明月清风,刚发现你给r赋了一个初值,但r是一个积分变量啊??呵呵

.5
r****a
发帖数: 3249
15
因为老是不成功,感觉是不是不能做,如果不能的话,应该怎么做变限双重积分呢?哪位达
人给个例子说说.谢了.
m*m
发帖数: 65
16
来自主题: Mathematics版 - 请教matlab里面一个双重积分的问题
对x,y积分,被积函数含有一个参数D,即被积函数f(D,x,y),x,y上下限已知,进行数
值积分如何得到结果含D的表达式,我用dblquad(),一直报错,请教大侠是不是命令
用错了,谢谢
(共0页)