在matlab中如何求偏导数,MATLAB中偏导数的计算

Your question is very difficult indeed. So far I cannot find any helpful information available either online or textbook to help me generate a correct solution indeed.

But here is my code to just get petty net result as you expect to apply in your question above. If you like it, don't forget to give me a thumb up! Cheers ~

- - - - - - - - - - - - - - - - - - - - c o d e - - - - - - - - - - - - - - - - - - - -

clear all

syms x y z

% define a function 'f' in terms of 'x', 'y' and 'z'

f = exp(z)-x*y*z;

zOFxy = sym('z(x,y)');

fprintf('\n')

% replace z with z(x,y)

f_zOFxy = subs(f, z, zOFxy);

disp('F(x,y,z) = ')

pretty(f_zOFxy)         % 1st print F(x,y,z)

fprintf('\n')

% 1st derivative with respect to x

dfx = diff(f_zOFxy, x);

% 2nd derivative with respect to y

dfxy = diff(dfx, y);

disp('F(x,y,z)'' = ')

pretty(dfxy)            % 2nd print F''(x,y,z)

dzOFxy = diff(diff(zOFxy, x), y);

syms Zxy Zx Zy Z

% replace the symbolic derivative like:

%   ∂

%  -- z(x,y) -> Zx

%  ∂x

%

%   ∂

%  -- z(x,y) -> Zy

%  ∂y

%   ∂

%  --- z(x,y) -> Zxy

%  ∂xy

df1 = subs(dfxy, diff(zOFxy, x), Zx);

df2 = subs(df1, diff(zOFxy, y), Zy);

df3 = subs(df2, dzOFxy, Zxy);

df4 = subs(df3, zOFxy, Z);

% move Zxy to the left side of equation

dzOVERdxy = solve(df4, Zxy);

pretty(dzOVERdxy)       % 3rd print Zxy = ....

- - - - - - - - - - - - - - - - - - - - c o d e - - - - - - - - - - - - - - - - - - - -

I don't know why I fail to find the code input selection on the tool box in this reply. Plain txt fomat might be quite indiscernible to read though. So my personal suggestion is to copy the code to your Matlab and the code should display like:

向左转|向右转

ba4d8b37319bfdaa3a713a2fa74902fc.png

After running my code, you should also generate the exactly same result as shown below.

向左转|向右转

c0460dba8e43f592e373fbbbb35b257c.png

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值