Search code examples
matlabsymbolic-math

Matlab differentiable symbol


I want to define a differntiable sym in MatLab so that

sym x y t;
eq = y == x;    
diff(eq,'t') = dy/dt == dx/dt

With this Code dy/dt and dx/dt are calculated and 0 is returned. How can I tell matlab that y and x are functions of t?

I do not know the explicit functions, so substituting y and x with their explicit functions is not an option.


Solution

  • What you are looking for is this-

    syms x(t) y(t)
    

    Define your functions as-

    x(t)='your function';
    y(t)='your function';
    

    And then calculate the differential as follows-

    diff(x) %since x is only a function of t
    diff(y) %since y is only a function of t