g***i 发帖数: 90 | 1 大家不妨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来了 | b*****y 发帖数: 163 | 2
it seems no problem at all, if you add ellipsis ... at the end of the
first line.
【在 g***i 的大作中提到】 : 大家不妨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来了
| g***i 发帖数: 90 | 3 no, of course u write in one line or use ...
here i don't mean syntax error, i mean bug.
try to run the two commands
so it seems strange, right? the two line r the
same, except i use "y" in one line and "p" in another
as the integration variable. but, their results r different
【在 b*****y 的大作中提到】 : : it seems no problem at all, if you add ellipsis ... at the end of the : first line.
| a*******x 发帖数: 47 | 4
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.
【在 g***i 的大作中提到】 : 大家不妨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来了
| g***i 发帖数: 90 | 5 thanks.
no, the error is not in the tolerance. the two results
r so different, one is correct.
and i tried "inline", still the same problem//in fact even
offer the wrong answer of the two
【在 a*******x 的大作中提到】 : : 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 | 6
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
【在 g***i 的大作中提到】 : thanks. : no, the error is not in the tolerance. the two results : r so different, one is correct. : and i tried "inline", still the same problem//in fact even : offer the wrong answer of the two
| g***i 发帖数: 90 | 7 but unfortunately, that two results are not the
correct one, which is 0.5.
【在 a*******x 的大作中提到】 : : 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
| a*******x 发帖数: 47 | 8 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
【在 g***i 的大作中提到】 : but unfortunately, that two results are not the : correct one, which is 0.5.
| t***h 发帖数: 5601 | 9 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/
【在 a*******x 的大作中提到】 : 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
| g***i 发帖数: 90 | 10 as i mentioned at the begining, this problem only appears
in matlab 6.0
what version do u use?
【在 a*******x 的大作中提到】 : 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
| a*******x 发帖数: 47 | 11 6.1. BTW, have you tried my code? what kind of results did you get?
Just out of curiosity.
【在 g***i 的大作中提到】 : as i mentioned at the begining, this problem only appears : in matlab 6.0 : what version do u use?
| g***i 发帖数: 90 | 12 i guess u must be using 6.1
in 6.1 no problem
test in 6.0, u'll c how strange it is:)
【在 a*******x 的大作中提到】 : 6.1. BTW, have you tried my code? what kind of results did you get? : Just out of curiosity.
| g***i 发帖数: 90 | 13 in 6.0, even if u use inline. it's still wrong.
and if u use functions, the case is WORSE//wrong for whatever variable
【在 a*******x 的大作中提到】 : 6.1. BTW, have you tried my code? what kind of results did you get? : Just out of curiosity.
| a*******x 发帖数: 47 | 14 OK, I see. Really strange!
【在 g***i 的大作中提到】 : in 6.0, even if u use inline. it's still wrong. : and if u use functions, the case is WORSE//wrong for whatever variable
|
|