Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Symbolic Differentiation in Matlab

  1. Aug 3, 2010 #1
    Hi, quick question.

    I have an inline function I would like to differentiate symbolically in Matlab, however when I do it I get the following:


    x = inline('cos(t.^2)','t') ;
    xp = inline(char(diff(x(t),sym('t'))),'t') ;

    xp(t) becomes


    however I really want:

    -sin(t.^2).*t (vectorial notation)

    I've looked at the diff function help, and it's a bit bare (as I would expect any symbolic manipulation functions to be in Matlab lol) and doesn't seem to say how I get this derivative to handle vectors the way I want it to...

    Thank you.
  2. jcsd
  3. Aug 4, 2010 #2
    Haha I just found the function 'vectorize' (which I had never used before).

    Pretty much you take any inline function and it will vectorize it for you.


    x = inline('cos(t.^2)','t') ;
    xp = inline(char(diff(x(t),sym('t'))),'t') ;




    Thanks and sorry to bother you guys :)
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook