diff - 数值差分和导数
使用格式:
Y = diff(X) %一阶差分和一阶导数
Y = diff(X,n) %n阶差分和n阶导数
实例:
①X = [1 1 1; 5 5 5; 25 25 25];
Y = diff(X)
Y =
4 4 4
20 20 20
②X = [1 3 5;7 11 13;17 19 23];
Y = diff(X,1,2)
Y =
2 2
4 2
2 4
③syms x
f = sin(x);
Y = diff(f) %一阶导数
Y =
cos(x)
Y = diff(f,2)
Y = diff(f,2) %二阶导数
Y =
-sin(x)