DSP: Best curve fitting approach via MATLAB?

Click For Summary

Discussion Overview

The discussion revolves around the challenges of curve fitting and smoothing techniques in MATLAB for experimental data that includes breaks in acquisition timing. Participants explore various methods to create a smooth curve that accurately represents the original data while accounting for these breaks.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes their experimental setup involving data collected in three 1-hour blocks with varying acquisition frequencies and expresses the need for a method to smooth the data while accounting for breaks.
  • Another participant suggests exploring frequency domain methods as a potential approach.
  • Several participants question the method of connecting breaks with linear interpolation and recommend using cubic spline interpolation or polynomial best fit as alternatives.
  • A participant mentions that they have performed linear interpolation and applied a smoothing filter, but still encounter artifacts at the breaks, suggesting the need for a different interpolation approach before smoothing.
  • One participant shares that after using linear interpolation and a smoothing function, they achieved satisfactory results, indicating a successful application of the discussed methods.

Areas of Agreement / Disagreement

There is no clear consensus on the best approach to smoothing the data, as participants propose different methods and express varying levels of success with their techniques. The discussion remains open-ended with multiple competing views on the most effective curve fitting strategy.

Contextual Notes

Participants highlight the complexity of the data set, including inconsistent time gaps and the challenge of interpolating differently for each sequence. The discussion reflects the limitations of linear interpolation in this context and the potential need for more sophisticated methods.

ElijahRockers
Gold Member
Messages
260
Reaction score
10
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!
 
Physics news on Phys.org
Can you do it in freq domain? Just throwing out ideas.
 
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
 
meBigGuy said:
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

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.
 
meBigGuy said:
See "interpolating missing data" here http://www.mathworks.com/help/matlab/data_analysis/missing-data.html

Duh, my brain. I see, thanks for the link. I performed a linear interpolation using interp1(), then sgolayfilt() to smooth the curve. The results are astounding, thanks!
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 12 ·
Replies
12
Views
7K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 5 ·
Replies
5
Views
12K