subs in symbolic equation
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Saeed Heysiattalab
el 21 de Mayo de 2021
Respondida: Hrishikesh Borate
el 25 de Mayo de 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 comentarios
Respuesta aceptada
Hrishikesh Borate
el 25 de Mayo de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Calculus en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!