Hi everyone,
So I have this problem, my university is giving us an assignment where we have to find the derivative without using the diff function. So we have an array of positions(y) and an array of time(t) and we have to find the derivative in order to find the speed.
I know I have to use this function (f(x + h) - f(x - h)) / (2*h), so I came up with this code:
fun = @(y,t) y/t;
dx = t(2)-t(1);
x = y(1);
df = (fun(x + dx) - fun(x - dx)) / (2*dx);
But it is giving me errors, specifically "Not enough input arguments. Error in @(x,t)x/t". What is the error? How can I calculate the derivative in order to find the speed?
Thanks in advance.
0 Comments
Sign in to comment.