Search code examples
matlabderivative

Matlab: evaluate second derivative


After I take second partial derivative of function f,

second_div = diff(f,pz,2);

second_div now should be a function of pz and u

I want to evaluate second_div at give (pz,u). How do I do that?


ATTEMPTS


second_div(2,3); <- failed because second_div is a 1*1 sym
vpa(subs(second_div,pz,u_m,2,3)); <- failed
vpa(subs(second_div,(pz,u_m),(2,3))); <- failed

Thanks.


Solution

  • See from mathworks.com/help/symbolic/subs.html that you substitute a list of variables in {}:

    syms f pz u
    f = u*pz^3
    second_div = diff(f,pz,2);
    subs(second_div,{pz,u},[3,4])
    

    which gives 72 as expected.