Take the 2-minute tour ×  How would I go about creating a
function in matlab which would calculate the following
$$M_c(f)=h \sum_{i=1}^N f(c_i)$$   $h=\frac{b-a}{N},
\\c_i=a+0.5(2i-1)h,\\ i=1,\ldots,N$  What I have tried so far is
function(M(f))= composite_midpoint(f)  for i=1:1:N    M(f) =
h*(sum + f)  Sorry about not inserting the matlab code directly,
I'm not sure how to do it.  share|improve this question Updated
the formatting, you can use four spaces in front of each line to
show code. –  Dennis Jaheruddin Nov 13 '12 at 16:41 What types
of 'functions' are you expecting to be able to input for f?
Symbolic functions, or matlab functions? –  icurays1 Nov 13 '12
at 16:42 It would be a function which is smooth enough for
Taylor's theorem and one which it's integral can be calculated
exactly. –  Nicky Nov 13 '12 at 16:49 Yes, but with matlab
functions are either .m files or "symbolic" functions. Its not
going to work the way you have it written if you call it like
"composite_midpoint(x^2)". It doesn't know