Effacer les filtres
Effacer les filtres

Solving Integrals with Matlab

3 vues (au cours des 30 derniers jours)
Jerald Johnson
Jerald Johnson le 22 Avr 2019
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))

Réponses (1)

Star Strider
Star Strider le 22 Avr 2019
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.)

Catégories

En savoir plus sur Numerical Integration and Differential Equations dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by