Substituting the partial differentiation

34 次查看(过去 30 天)
I am trying to substitute the partial differential equation but I can't find appropriate function.
Here is the sample code I have to modify.
syms u v x(u,v) y(u,v) z(x,y)
z = exp(x*y) ;
x = 2*u+v ;
y = u/v ;
dx = diff(x,u)
dy = diff(y,u)
dz_du = diff(z,u)
dz_du = subs(dz_du, {diff(x,u),diff(y,u)}, {dx, dy})
The result is
dx =
2
dy =
1/v
dz_du(u, v) =
exp(x(u, v)*y(u, v))*(y(u, v)*diff(x(u, v), u) + x(u, v)*diff(y(u, v), u))
dz_du(u, v) =
exp(x(u, v)*y(u, v))*(y(u, v)*diff(x(u, v), u) + x(u, v)*diff(y(u, v), u))
The point is, those diff(x(u, v), u) & diff(y(u, v), u) haven't substituted.
(what I want is the result below)
exp(x(u, v)*y(u, v))*(y(u, v)*2 + x(u, v)*1/v)
*At first, I changed the last line
subs(dz_du, {diff(x(u,v),u),diff(y(u,v),u)}, {dx, dy})
but it only returns error.
** I found some answers asking the version of my MATLAB and it is R2021a
Is there any way to guide matlab to substitute those partial differentiations?
  3 个评论
VBBV
VBBV 2023-7-25

It seems you have defined z = exp(x*y) first. You should define it after x and y. Then do the diff(z,u) which will give the same result but in u and v. There's no need for subs in the equation

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by