Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function int = trapcomp(f, m, a, b)
- h=(b-a)/m;
- y=zeros(1,m);
- for i=1:m
- y(i)=f(a + i*h);
- end
- int = (h/2)*(f(a) + f(b) + 2*sum(y(1:m-1)));
- end
- %trapcomp(f,32,0,4)-integral(f,0,4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement