📄 numder.m
字号:
function der = numder(fun, x, h, n, varargin)
% Approximation der of the first order derivative, at the point x,
% of a function named by the string fun. Parameters h and n
% are user supplied values of the initial step size and the number
% of performed iterations in the Richardson extrapolation.
% For fuctions that depend on parameters their values must follow
% the parameter n.
d = [];
for i=1:n
s = (feval(fun,x+h,varargin{:})-feval(fun,x-h,varargin{:}))/(2*h);
d = [d;s];
h = .5*h;
end
l = 4;
for j=2:n
s = zeros(n-j+1,1);
s = d(j:n) + diff(d(j-1:n))/(l - 1);
d(j:n) = s;
l = 4*l;
end
der = d(n);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -