MATLAB CODE Write a function with the header which calculate

MATLAB CODE:

Write a function with the header which calculates the partial derivative using the central difference method of function f with respect to x (ind). The central difference approximation of a function evaluated at x is: f = f (x + h)-f (x - h)/2epsilon and eps is used to permute x (ind) such that

Solution

The Code is here for function

------------------------------------------------------

function [df ] = myPartial(f,x,ind,eps )
%MYPARTIAL Summary of this function goes here
% Detailed explanation goes here

if ind==1
h=[eps;0;0];
elseif ind==2
h=[0;eps;0];
  
elseif ind==3
h=[0;0;eps];
end

df=(f(x+h)-f(x-h))/(2*eps);
  
end

-----------------------------------------------------------------

MATLAB CODE: Write a function with the header which calculates the partial derivative using the central difference method of function f with respect to x (ind).

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site