help me, why is it invalid use of operator?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
can you guys help me? this is the code im having problem with:
% Simpson's 1/3 Rule for finding integration of x
the function that i want to use is this:
please help me. thank you!
0 commentaires
Réponses (1)
David Hill
le 21 Juil 2020
Not sure if you have additional constraints, but if your functions are all polynomials, the polyint function works well.
p=[-.0729,1.171,-13.8,4,-1];
intP=diff(polyval(polyint(p),[a,b]));%where a and b are the lower and upper bounds
2 commentaires
David Hill
le 21 Juil 2020
f=@(x)-.0729*x.^4+1.171*x.^3-13.8*x.^2+4*x-1;%here is how you write the function
David Hill
le 21 Juil 2020
Where a,b,and n are input like above
f=@(x)-.0729*x.^4+1.171*x.^3-13.8*x.^2+4*x-1;
x=linspace(a,b,n+1);
y=f(x);
intF=(b-a)/3/n*(f(a)+f(b)+4*sum(y(1:2:end))+2*sum(y(2:2:end)));
Voir également
Catégories
En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!