trapr1 - %%%to use a made up function %%set...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function s=trapr1(f,a,b,M) h=(b-a)/M; s=0; for k=1:(M-1) x=a+h*k; s=s+feval(f,x); end s=h*(s+(feval(f,a)+feval(f,b))/2);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %%%to use a made up function %%set f=inline('function') %%then s=trapr1(f,0,5,40)...
View Full Document

This note was uploaded on 09/11/2011 for the course MECH 231 taught by Professor Den during the Spring '11 term at Rutgers.

Ask a homework question - tutors are online