필터 지우기
필터 지우기

Solving Integrals with Matlab

조회 수: 2 (최근 30일)
Jerald Johnson
Jerald Johnson 2019년 4월 22일
답변: Star Strider 2019년 4월 22일
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))

답변 (1개)

Star Strider
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.)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by