I tried to create a mid point formula and trapezoid formula in Matlab and solve a integral using it but I'm not getting the same result as the build in function.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
we are trying to use these two formula to approximate a integral value. instead of using the build in function of
format long
integral(@(x)exp(-x.^4),0,20)
but the result should match the result of build in function.
we are trying to approxiamte this integral
my code is follows
a = 0;
b = 20;
n = 10000;
h = (b-a)/n;
x = linspace(a,b,n+1);
y = exp(-x.^4);
x_mid = a+h/2:h:b;
t_form = h*(sum(y)+((y(1)+y(end))/2))
my result doesn't match the original result. But i'm not sure where the problem is.
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!