matlab - Use derivative of function directly as an anonymous function -
i ask, if possible create anonymous function directly return value after using diff function? without copy text console , add manually anonymous function.
eg.
xy @(x)=diff(x^2,x);
and using afterwards as: xy(3)
, on.
you can use symfun
symbolic function:
syms x f(x) = x^2; % equivalent to: f = symfun(x^2,x); df = diff(f,x) % since f symfun, df df(3)
which returns
df(x) = 2*x ans = 6
Comments
Post a Comment