Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

DSP: Best curve fitting approach via MATLAB?

  1. Sep 25, 2015 #1

    ElijahRockers

    User Avatar
    Gold Member

    I am doing an experiment that generates data in three 1-hour-blocks. Each block has a different number and timing for acquisitions. (The first hour is more frequent and numerous, while the last hour is only 6 acquisitions)

    The reason for breaking it up into 3 hours is to give the subjects a break from the experiment. My ultimate goal is to try to account for the break times (perhaps just linearly interpolating where the breaks should be), and create a new curve that is a smoothed version of the original data with the breaks added.

    Unfortunately I run into a bit of a speed bump, when I try a smoothing filter, there seems to be an artifact where the breaks are, I believe because of the discontinuities (both in value, and probably in time also).

    Does anyone have any advice as to how I might best go about constructing a smooth curve based on this data? Polyfit is just not faithful enough to the original data.

    This is a link to two graphs, the top graph being the data with break times inserted into the x-axis, whereas the bottom graph is the same plot after a smoothing filter.

    Thanks in advance!
     
  2. jcsd
  3. Sep 25, 2015 #2
    Can you do it in freq domain? Just throwing out ideas.
     
  4. Sep 27, 2015 #3

    meBigGuy

    User Avatar
    Gold Member

    It's hard for me to tell where the breaks are. Are you just connecting the breaks with straight lines (linear interpolation) and then trying to filter out the discontinuities?

    You would be better off with cubic spline interpolation or some other sort of polynomial best fit.

    https://en.wikipedia.org/wiki/Spline_(mathematics)

    WHat does the MATLAB manual say about interpolation?
    See "interpolating missing data" here http://www.mathworks.com/help/matlab/data_analysis/missing-data.html
     
  5. Oct 2, 2015 #4

    ElijahRockers

    User Avatar
    Gold Member

    Yea, the time gaps have been linearly interpolated by MATLAB, at least as far as the plotting goes..

    I have corrected the data so it now looks like a relatively smooth curve (i.e. there are no large 'kinks' in the curve), but it has yet to be actually smoothed. Whenever I do the smoothing, I still get large discontinuous looking artifacts at the first break, I assume because the time gap is so much larger.

    Would it be better to interpolate those points and THEN do the smoothing? The problem is I have a large data set and the time gaps are not consistent, I would have to interpolate a little differently for each sequence.
     
  6. Oct 2, 2015 #5

    ElijahRockers

    User Avatar
    Gold Member

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: DSP: Best curve fitting approach via MATLAB?
  1. Music DSP (Replies: 1)

  2. Dsp fourier (Replies: 4)

  3. Career in DSP (Replies: 8)

  4. Best matlab book? (Replies: 1)

  5. Windowing (DSP) (Replies: 5)

Loading...