Message Boards Message Boards

GROUPS:

Taking Derivatives of Experimental Data

Posted 10 years ago
4757 Views
|
5 Replies
|
4 Total Likes
|
I'm using a fiber optic displacement sensor to monitor the motion of a bead pack as it's being vertically shaken.  The shaker shakes the beads vertically with a sin wave of a given amplitude and frequency.  I am trying to take the displacement data I get from this and take two derivatives so that I can compare the acceleration from the data with the acceleration picked up by the accelerometer. 


I was able to successfully import my data and plot the position vs. time function correctly but when I try to plot its derivative the graph is unbelievable noisy for the first derivative and much worse for the second.  Is there any way I can fix this?
data = Import["C:\\Users\\PhysicsUser\\Desktop\\Thesis\\Data Stream\\data stream 1Vpp 30Hz beadpack.xlsx"];
f = Interpolation[data[[1]]];
Plot[f[x], {x, 0.75,0.9}, PlotRange -> {15.45,16.8}]
Plot[f''[x], {x,0,1.1}, PlotRange -> {15.0, 17.0}]
The first plot is perfect... the second plot is an absolute mess
POSTED BY: A Johnson
5 Replies
Interpolation has the default Option
InterpolationOrder -> 3
 One thing to try wold be to change this to a slighly higher fit order and see if your issue still occurs
InterpolationOrder -> 4
 In effect this supplies a bit of somoothing by interpolationg with a higher order polynomial.  When you use InterpolationOrder -> 3 the second derivative is in effect a linear fit to the data's derivative which may well be quite choppy
POSTED BY: David Reiss
Posted 10 years ago
Others have had difficulties with getting a sensible fit.

http://mathematica.stackexchange.com/questions/2309/problem-with-nonlinearmodelfit/2327#2327

Perhaps some of the responses to that will help.

If I slice away most of the detail of that and restrict the number of parameters just to show a tiny example
In[1]:= v = Table[4*Sin[2 Pi x] + RandomReal[{-.5, .5}], {x, 0, 2 Pi, .05}];
Normal[NonlinearModelFit[v, y0 + A*Sin[x w], {y0, A, w}, x, Method -> NMinimize]]

Out[2]= 0.00385365 + 3.95021 Sin[0.313225 x]

In[3]:= Show[ListPlot[v], Plot[%, {x, 0, 2 Pi*20}]]

Out[3]= ...PlotSnipped...

You should definitely repeat all this, perhaps with fewer cycles and more noise and more parameters to see if you are confident you have captured the idea.

Then try it on your real data and see if the fit has looked past the noise in your data and done a good job at estimating the actual positions.
Then take a look at the second derivative and see if it is reasonable.
POSTED BY: Bill Simpson
Perhaps you would like to use discrete derivatives given by Differences function to operate directly on data, not their fits, and then fit those by smooth curves? Also, is it possible to post data somewhere, here if it is reasonable size, or as a download at a DropBox site or similar?
POSTED BY: Sam Carrettie
Posted 10 years ago
how would I go about doing that? I searched around for something similar and tried it and all i got was a line for the sine fit :/
POSTED BY: A Johnson
Posted 10 years ago
Fit a sine wave to the raw data, that looks past some of the noise in the data, take the second derivative of the sine wave and see if that is a credible estimate?
POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract