Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Re: diff and gradient function, derivative of a vector
Posted:
Jul 16, 2010 11:51 AM


"Yi Cao" <y.cao@cranfield.ac.uk> wrote in message <i1p2vn$556$1@fred.mathworks.com>... > "Md. Shahriar Karim" <karim.shahriar@gmail.com> wrote in message <i1oouo$a1o$1@fred.mathworks.com>... > > Hi, > > > > I am given a vector say A= [.....................] that describe a function say f(x). Now, I have to calculate the derivetive d(A)/d(x). x = 1: N and is equally spaced with any equal width (0.1 or 0.5 or 1 or anything). I was using both > > diff (A) > > gradient (A) > > > > however, the derivative value I get using diff and gradient result in different output when cascaded to in next calculation. Becasue, my last calculation is highly sensitive of derivative (d(A)/d(x)) value as the derivative value I am using to plot the cramerrao bound for an estimator. > > > > Could you please say which process amongst diff (A) and gradient (A) is more accurate in finding the derivative of a vector? > > > > Is there anyother way that can be used to obtain the same with even greater accuracy? Thanks, > > > > > > Karim > > Neither diff nor gradient is reliable in this application. You can use either finite difference (FD) or automatic differentiation (AD) to calculate dA/dx. There are some tools in File Exchange available for both FD and AD. For example: > > For FD, my Complex Step Jacobian tool will be useful, http://www.mathworks.com/matlabcentral/fileexchange/18176 > To use this tool, if your function has transpose ('), you have to convert it to (.'). > > For AD, the recent submission may be useful: > http://www.mathworks.com/matlabcentral/fileexchange/26807 > > HTH > Yi
Hi, if i use the adiff function to calculate the derivative, how will we use this? For example, vecotr A = [1......N] is describing the function but we do NOT know what kind of equation does it have. All we know is that the function has some value on some different points (X = 1,2,... ....say 30)).
How would the adiff and adiffget would fit in this case? I saw that to use adiffget we have got to have a existing equation that governs the relation between X (points where derivative to be calculation) and function (X).
Thanks,
Thanks,
Shahriar



