matlab中函数赋值的问题怎么解决?

2025-02-27 17:15:52
推荐回答(1个)
回答1:

clear;
clc;
syms x y z
f = 3*x+4*y*z;
fx = diff(f,'x') %%%% 对x求偏导
fy = diff(f,'y') %%%% 对y求偏导
fz = diff(f,'z') %%%% 对z求偏导
my_fx = subs(fx,{x,y,z},{1 2 3}) %%%%% 对dx数值代入
my_fy = subs(fy,{x,y,z},{1 2 3}) %%%%% 对dy数值代入
my_fz = subs(fz,{x,y,z},{1 2 3}) %%%%% 对dz数值代入