The error you have is most likely a simple function call. I tried to reproduce your error, but the only way to do that was to call a function with the wrong name, for example
f = @(x) 2*x+1;
Undefined function 'midpointse' for input arguments of type 'function_handle'.
To solve that problem, try to copy the function midpoints to a new file, delete the old file and then save the new file. The thing is that a matlab function (those created by typing function in the beginning), needs to be saved in a file with the same name. Then make sure to call the function with correct syntax.
However, your problems may not end there. There are a few different types of functions in matlab. The one I choose to call a matlab function is one type.
An other way to do it is as an "anonymous function". The call is f = @(x) a*x+b+1. When this definition is made then a and b must be set. This function works in large the same way a matlab function except that you do not need an .m-file. this does also mean that if you want a anonymous function to return a vector, the you need to define the function as f = @(x) a.*x+b+1. More important you cannot use symbolic differentiation diff(f,x) when you have an anonymous function. The variable x (or rather all variables declared within the @()) for an anonymous function is, just like any matlab function only defined in the local scope. That means also that a function handle is unable to pass a variable to a function. You have probably mixed this up with a "symbolic function", which may look similar at a first glance.
An symbolic function is special. That function creates a "symbolic expression" Which may consist of multiple symbols, syms. However these variables need to be defined before the symbolic expression is written. A sym exactly work as any other types in matlab in the sense that unless defined global (which you probably do not want to do with x, since you may have x in a lot of functions) the variable will not be defined inside midpoints. Also, writing syms x is really only a short way for writing x = sym('x'), which means that a variable named x is assigned a value x which is of the type sym.
Looking at this it is clear the the preferred function for you is the symbolic function. To be able to differentiate h with respect to x, the best way is to pass symbols as variables (so that the variable can have another value than x and not cause problems).
function [f1,out] = symFunExample(f,a,x)
f1 = diff(f,x); out = subs(f,x,1); out = out+a;
This function is then called as: syms x; f = 2*x+2; a = 1; symFunExample(f,a,x).