Prev: replace object properties
Next: netcdf.open problem
From: Estee on 28 Jun 2010 15:30 Hi, I have an array of numbers, for example x = [1 2 3 4 5]. I want to find the (approximate) derivative for array x. On the MatLab site, a suggestion to approximate the derivative looks like this: y = diff(x); derivative = diff(y) ./ diff(x) However, since diff(array) shortens the length by 1, the top and bottom are of different sizes and causes an error. Does anyone know how to fix this, or know a better way to approximate derivatives of an array of numbers? Thanks! =] Estee
From: dpb on 28 Jun 2010 15:31 Estee wrote: > Hi, > I have an array of numbers, for example x = [1 2 3 4 5]. > I want to find the (approximate) derivative for array x. On the MatLab > site, a suggestion to approximate the derivative looks like this: > y = diff(x); > derivative = diff(y) ./ diff(x) However, since diff(array) shortens the > length by 1, the top and bottom are of different sizes and causes an error. > > Does anyone know how to fix this, or know a better way to approximate > derivatives of an array of numbers? .... You can fit some functional form and analytically differentiate that function. doc polyfit for one choice... --
|
Pages: 1 Prev: replace object properties Next: netcdf.open problem |