I have a continuous function of two variables:
f = @(x,y) x.^2 + (y-1).^2
How do I calculate a derivative of this function numerically? I tried two different ways and got errors:
% First try
df = @(x,y) diff(f(x,y),x)df(1,2)ans = []% Second try
df = @(x,y) diff(f,x)df(1,2)Undefined function 'diff' for input arguments of type 'function_handle'
I must not set the derivative separately.
Best Answer