Can I control the number of output points in a smoothing spline fit?
1 次查看(过去 30 天)
显示 更早的评论
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!