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

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -