Can I control the number of output points in a smoothing spline fit?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Interpolation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!