DSP: Best curve fitting approach via MATLAB?

In summary, the researcher is trying to create a new curve that is a smoothed version of the original data, but runs into a bit of a speed bump. They use cubic spline interpolation to smooth the curve, and the results are astounding.
  • #1
ElijahRockers
Gold Member
270
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
  • #2
Can you do it in freq domain? Just throwing out ideas.
 
  • #3
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
 
  • #4
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.
 
  • #5
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!
 

FAQ: DSP: Best curve fitting approach via MATLAB?

1. What is DSP and how is it used in MATLAB?

DSP stands for Digital Signal Processing and it is a branch of science and engineering that deals with the processing of digital signals. MATLAB is a programming language and software environment that is commonly used for DSP due to its powerful tools and algorithms for signal processing.

2. What is the best approach for curve fitting using MATLAB?

The best approach for curve fitting using MATLAB depends on the specific data and application. Some commonly used approaches include least squares regression, interpolation, and nonlinear optimization. It is important to carefully consider the data and choose the most appropriate approach for the specific problem at hand.

3. How do I choose the best model for curve fitting in MATLAB?

Choosing the best model for curve fitting in MATLAB involves a combination of experience, knowledge of the data, and trial and error. It is important to understand the underlying principles of the data and consider different models to determine which one best fits the data. Additionally, using techniques such as cross-validation can help in evaluating the performance of different models.

4. Can I use MATLAB for curve fitting with complex data?

Yes, MATLAB has powerful tools for curve fitting with complex data. It can handle complex numbers, multi-dimensional arrays, and non-linear data. However, it is important to carefully consider the appropriate approach and model for the specific type of complex data being analyzed.

5. Are there any limitations to curve fitting using MATLAB?

Like any software, MATLAB has limitations for curve fitting. It is important to understand the underlying principles and assumptions of the data being analyzed in order to choose the most appropriate approach and model. Additionally, it is important to carefully consider the accuracy and reliability of the results when using any software for curve fitting.

Similar threads

Replies
6
Views
4K
Replies
4
Views
5K
Replies
5
Views
2K
Replies
11
Views
3K
Replies
1
Views
4K
Replies
5
Views
11K
Replies
2
Views
6K
Back
Top