subs in symbolic equation
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Saeed Heysiattalab
le 21 Mai 2021
Réponse apportée : Hrishikesh Borate
le 25 Mai 2021
Hello.
I have calculated a partial derivative of a function as following:
clear
clc
syms x y r t real
f = @(r,t) r.*cos(t);
df_r = diff(f,r);
df_t = diff(f,t);
r = @(x,y) sqrt(x.^2 + y.^2);
dr_x = diff(r,x);
t = @(x,y) atan(y,x);
dt_x = diff(t,x);
df_x = df_r*dr_x + df_t*dt_x
the result is :
df_x =
(x*cos(t))/(x^2 + y^2)^(1/2) + (r*y*sin(t))/(x^2 + y^2)
How can I get the df_x in only r and t. I would like to substititute x^2+y^2 with r^2, x with r*cos(t) and y with r*sin(t).
Thanks
0 commentaires
Réponse acceptée
Hrishikesh Borate
le 25 Mai 2021
Hi,
It’s my understanding that you are trying to obtain df_x in terms of r and t. Following addition to the existing code will do the same:-
syms r t
df_x = subs(df_x, x.^2+y.^2, r.^2);
df_x = subs(df_x, [x,y], [r*cos(t),r*sin(t)]);
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Calculus dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!