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)$
where
$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) h=(b-a)/N for i=1:1:N c_i=a+0.5*(2i-1)*h M(f) = h*(sum + f) end
Sorry about not inserting the matlab code directly, I'm not sure how to do it.