Trapezoidal method

by

 

Trapezoidal method

Tixing.m
function T=Tixing(f,t,n)
%f:x:䡣n:nȷ֡
syms x
h=(t(2)-t(1))/n;
ti=linspace(t(1),t(2),n+1);
s=0;
for i=2:n
    s=s+subs(f,x,ti(i));
end
T=h*(subs(f,x,ti(1))+2*s+subs(f,x,ti(n+1)))/2;


    

Contact us