Can I control the number of output points in a smoothing spline fit?

조회 수: 1 (최근 30일)
Jenna Wardini
Jenna Wardini 2018년 7월 29일
편집: Jenna Wardini 2018년 7월 29일
I am using the 'fit' function in matlab to simultaneously smooth and interpolate a noisy data set I have.
Specifically, I want to use the smoothing spline fit that can be accessed through the curve fitting tool app.
I need to be able to choose the number of output points in the fit so I can match it up with a corresponding measurement I took that has a higher data sampling rate.
To clarify, my noisy data set I want to smooth/interpolate points for has 300 points, and my corresponding measurement has many 1000's of data points.
Is there a simple way to do this? I don't see options to control the # of output points in the documentation.
Here is my code:
[xData, yData] = prepareCurveData( pixStrain_index,
pixStrain_strain );
% Set up fittype and options.
ft = fittype( 'smoothingspline' );
opts = fitoptions( 'Method', 'SmoothingSpline' );
opts.SmoothingParam = 0.0571743604633104;
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );
% Plot fit with data.
figure( 'Name', 'SmoothingSpline' );
h = plot( fitresult, xData, yData );
'SmoothingSpline', 'Location', 'NorthEast' );
h = findobj(gca,'Type','line')
y =get(h,'Ydata') %strain
x =get(h,'Xdata') %index
pixStrain_index_interp = x{1, 1}
pixStrain_interp = y{1,1}
The number of points in pixStrain_interp is 1265, I need it to be something like 30,000 points.
  댓글 수: 2
madhan ravi
madhan ravi 2018년 7월 29일
Can you upload your code?
Jenna Wardini
Jenna Wardini 2018년 7월 29일
Hi Madhan, I just pasted it under my question. I think this is not how you're supposed to do it but it is my first time posting so still getting the hang of things.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by