Getting 0 when using quad
조회 수: 7 (최근 30일)
이전 댓글 표시
fun = @(x) 80*exp(-((x-pi)/0.002).^2);
I = quad(fun,0,6)
I2= integral(fun,0,6)
I =
0
I2 =
1.464129900321425e-69
Why do I get 0 when using quad?
Best regards Aldo
댓글 수: 0
답변 (2개)
Walter Roberson
2016년 11월 11일
편집: Walter Roberson
2016년 11월 11일
The two use different adaptive techniques. The function has a sharp peak at Pi and one technique misses it completely and the other barely catches it. The actual integral over that range is (2/25*(erf(500*Pi)+erf(3000-500*Pi)))*sqrt(Pi) which is about 0.284
To get a better answer:
integral(fun,0,6,'Waypoints', pi)
댓글 수: 2
Walter Roberson
2016년 11월 11일
I wouldn't solve it with quad(). I might solve it with quadgk
quadgk(fun,0,6, 'waypoints', pi)
KSSV
2016년 11월 11일
You are trying to calculate the area under the curve as shown in the attached image. See the values on the axes, so I think getting zero is legitimate.

댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Marine and Underwater Vehicles에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!