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 Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by