名称:Jacobian matrix 雅可比矩阵 用法:jacobian(f,v) 描述:jacobian(f,v) computes the Jacobian matrix of f with respect to v. The (i,j) element of the result is jacobian(f,v) 计算了 f 关于 v 的雅可比矩阵,其第(i,j )个元素为. 输入参数说明: f — Scalar or vector function symbolic expression | symbolic function | symbolic vector 标量或者向量函数,符号表达式、符号函数、符号向量等。 如果f是一个标量的话,f 的雅可比矩阵是 f 的梯度的转置。 v — Vector of variables with respect to which you compute Jacobian symbolic variable | symbolic vector 要计算雅可比的变量向量,符号变量、符号向量 如果v 是一个标量,则结果等价于 diff(f,v) 的转置。 如果v 是空符号对象,比如sym([ ]),则结果返回空符号对象。 例子1:Jacobian of Vector Function The Jacobian of a vector function is a matrix of the partial derivatives of that function. Compute the Jacobian matrix of [x*y*z, y^2, x + z] with respect to [x, y, z]. 向量函数的雅可比矩阵式 该函数的偏微分,比如计算 [x*y*z, y^2, x + z] 关于 [x, y, z] 及[x; y; z]的代码及过程分别如下: syms x y z jacobian([x*y*z, y^2, x + z], [x, y, z]) jacobian([x*y*z, y^2, x + z], [x; y; z]) ans = [ y*z, x*z, x*y] [ 0, 2*y, 0] [ 1, 0, 1] 例子2:Jacobian of Scalar Function The Jacobian of a scalar function is the transpose of its gradient. Compute the Jacobian of 2*x + 3*y + 4*z with respect to [x, y, z]. 标量函数的雅可比为其梯度的转置,比如计算2*x + 3*y + 4*z 关于 [x, y, z]的雅可比的代码及过程如下: syms x y jacobian([x^2*y, x*sin(y)], x) ans = [ 2, 3, 4] 接着计算相同表达式的梯度: gradient(2*x + 3*y + 4*z, [x, y, z]) ans = 2 3 4 例子3:Jacobian with Respect to Scalar The Jacobian of a function with respect to a scalar is the first derivative of that function. For a vector function, the Jacobian with respect to a scalar is a vector of the first derivatives.. Compute the Jacobian of [x^2*y, x*sin(y)] with respect to x. 函数对于一个标量的雅可比矩阵为该函数的一阶微分。 向量函数对于一个标量的雅可比矩阵式一阶微分的向量。 比如,计算[x^2*y, x*sin(y)] 关于 x的雅可比矩阵如下: syms x y jacobian([x^2*y, x*sin(y)], x) ans = 2*x*y sin(y) 接着,计算微分: diff([x^2*y, x*sin(y)], x) ans = [ 2*x*y, sin(y)]
|