- #1

- 98

- 0

Code:

```
function [fprime]=numderivative(f,x,h,tol)
hd=h*10^-1;
hh=h;
hhdd=hd;
itnum=numel(x);
error=tol+1;
for ii=1:itnum
while error>tol
fprime1=(f(x(ii)+h)-f(x(ii)))/h;
fprime2=(f(x(ii)+hd)-f(x(ii)))/hd;
error=abs(fprime1-fprime2);
h=h*10^-1;
hd=h*10^-1;
end
fprime(ii)=fprime1;
h=hh;
hd=hhdd;
error=tol+1;
end
```

Need help.

Thanks

link