When you do diff of a vector of n elements it just outputs another vector of n-1 elements with the consecutive differences.. so when you put a 1 element vector you get an empty one.
A way to go would be to decide an epsilon
and use the Newton's difference quotient:
epsilon = 1e-10;
f = @(x) x^2+2*x+1;
f1 = @(x) (f(x+epsilon) - f(x)) / epsilon;
or just do the math and write down the formula:
f1 = @(x) 2*x+2;