subs in symbolic equation

조회 수: 2 (최근 30일)
Saeed Heysiattalab
Saeed Heysiattalab 2021년 5월 21일
답변: Hrishikesh Borate 2021년 5월 25일
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

채택된 답변

Hrishikesh Borate
Hrishikesh Borate 2021년 5월 25일
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)]);
For more information refer to subs.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by