Solving Integrals with Matlab
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi everyone, i am working on a calculus problem that requires me to use Lobatto Quadrature and Global Adaptive Quadrature but i keep getting an error. Could someone explain how to write a code for this? Thanks.
Problem: f(x)=integral sign(3x^2)dx. Upper bound is 8 and lower bound is 0 on the integral sign.
% Lobatto Quadrature
A3= quadl(@(3*x,x(1),x(end))
% Global adaptive quadrature
intfun=@(x) (3*x.^2)
A4=integral(Intfun,x(1),x(end))
댓글 수: 0
답변 (1개)
Star Strider
2019년 4월 22일
There is an error in the anonymous function in ‘A3’, and since MATLAB is case-sensitive, ‘Intfun’ is not the same as ‘intfun’. Also note that the functions for ‘A3’ and ‘A4’ are different.
This runs:
% Lobatto Quadrature
A3= quadl(@(x)3*x,x(1),x(end))
% Global adaptive quadrature
intfun=@(x) (3*x.^2)
A4=integral(intfun,x(1),x(end))
(I provided my own ‘x’ vector to test it.)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!