MATLAB: How can i change x to (x+h) replacing This is my function, f(x)=x^2 – 4 and f(x+h)=(x+h)^2 – 4 f=@(x) x.^2- 4; f=@(x+h) x.^2- 4 (this gives me error) How can i write f(x+h) ? Best Answer I am not certain what problem you are having. You have to define all the values you pass to your function as arguments before calling your function. Example —f = @(x) x.^2- 4;h = 1E-8;dfdx = @(f,x,h) (f(x+h) - f(x))./h;x = 4;fval = f(x)derv = dfdx(f,x,h) Related SolutionsMATLAB: How to put a function in another function Yusuke - if x is the input parameter to your function h, then you must pass this into f and g as well. So instead of h = @(x) (f+5*g)/(2*f*g);you would write h = @(x) (f(x)+5*g(x))/(2*f(x)*g(x));Try the above and see what happens! MATLAB: Decimal places for value stored You can use round()x=4.21;h=0.001;f=@(x) x^3 + 8*x^2 + 23*x +3;f2_prime = (round(f(x+h),4)-2*f(x)+round(f(x-h),4))/(h^2); Related QuestionHow to define a special function with some pointsHow can i plot error=abs(x(i)-x(i-1)) with the couynting of i. Ihave the following code.I need your HELP!!!!
Best Answer