I need help on matlab. Someone help me please. Given a function f(x) and a vector \(x=x_0,x_1,x_2,...x_N)\) output a vector of approximations for f'(x) at \(x_0,x_1,...,x_{N-1}\) using the difference quotient
Am I understanding the problem well? Suppose your vector is sorted.\[f'(x_k) \approx \frac{1}2 \left(\frac{f(x_k) - f(x_{k-1})}{x_k - x_{k-1}} + \frac{f(x_{k+1})-f(x_{k})}{x_{k+1 }-x_{k}} \right)\]This works, but for better accuracy, use weighted means. It should be weighted more towards the place where the difference is less.
I need create a function on matlab with those condition but I don't know why I can't run it. Can you please help me step by step?
I can help you with the math, but not MATLAB. :(
Like step1: click on "new " and choose "function" step2: create the name of function step3: Save it on matlab document step4:... I screw it up any time I work on matlab. :(
Join our real-time social learning platform and learn together with your friends!