diff函数

diff函数为求导函数,调用格式为diff(f,x,n),其中f为函数,x为求导变量(f中的其他字母视为常量),n为求导次数,缺省情况下为1.

>> syms b n;
>> m=n*n-5*n+b*n*n*n;
>> diff(m,n,1)

这里写图片描述

MATLAB中解释为:

>> help diff
 DIFF Difference and approximate derivative.
    DIFF(X), for a vector X, is [X(2)-X(1)  X(3)-X(2) ... X(n)-X(n-1)].
    DIFF(X), for a matrix X, is the matrix of row differences,
       [X(2:n,:) - X(1:n-1,:)].
    DIFF(X), for an N-D array X, is the difference along the first
       non-singleton dimension of X.
    DIFF(X,N) is the N-th order difference along the first non-singleton 
       dimension (denote it by DIM). If N >= size(X,DIM), DIFF takes 
       successive differences along the next non-singleton dimension.
    DIFF(X,N,DIM) is the Nth difference function along dimension DIM. 
       If N >= size(X,DIM), DIFF returns an empty array.

    Examples:
       h = .001; x = 0:h:pi;
       diff(sin(x.^2))/h is an approximation to 2*cos(x.^2).*x
       diff((1:10).^2) is 3:2:19

       If X = [3 7 5
               0 9 2]
       then diff(X,1,1) is [-3 2 -3], diff(X,1,2) is [4 -2
                                                      9 -7],
       diff(X,2,2) is the 2nd order difference along the dimension 2, and
       diff(X,3,2) is the empty matrix.

    See also gradient, sum, prod.

    Overloaded methods:
       char/diff
       sym/diff
       fints/diff
       iddata/diff

    Reference page in Help browser
       doc diff
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

永远的水面

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值