Hello,
I'm trying to derive a symbolic function that is a function of another symbolic function. Say that I have a function x that is an unspecified function x=x(y(theta)). I'd like to take the derivative of x with respect to theta: dx/dtheta=dx/dy * dy/dtheta
In Matlab I write
syms theta y(theta);
x=sym('x(y(theta))');
diff(x,theta)
The answer I get is 0. I really cannot figure out what is wrong with the code. Any help is greatly appreciated. Thanks!

 Réponse acceptée

Star Strider
Star Strider le 5 Avr 2014

3 votes

This:
syms theta y(theta) x(y)
x = x(y)
Dyt = diff(y,theta)
Dxt = diff(x,theta)
produces:
x =
x(y(theta))
Dyt(theta) =
D(y)(theta)
Dxt =
D(x)(y(theta))*diff(y(theta), theta)
Is that what you wanted?

6 commentaires

Nicola
Nicola le 5 Avr 2014
Thanks, this works!
Star Strider
Star Strider le 5 Avr 2014
My pleasure!
Mr.Gh
Mr.Gh le 16 Août 2020
I am trying to find the derivative of "A" with respect to "a", but I get some errors:
syms t a(t) b(t) A(a,b)
A = a^2 + b^2;
B = formula(A);
aS = formula(a);
D_A_t = diff(B,aS);
error:
Error using sym/diff (line 70)
Second argument must be a variable or a nonnegative integer
specifying the number of differentiations.
Error in (line 5)
D_A_t = diff(B,aS);
Please advise.
Star Strider
Star Strider le 16 Août 2020
Post this as a new Question. Much has changed in the last 6 years. Be sure to mention the version/release of MATLAB that you are using.
Meet Mevada
Meet Mevada le 21 Mar 2021
Thanks man.This helped me a lot.
Star Strider
Star Strider le 21 Mar 2021
Meet Mevada — My pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Financial Toolbox dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by