fitting a smooth curve

12 views (last 30 days)
Busy Bee
Busy Bee on 31 Jan 2018
Commented: Busy Bee on 31 Jan 2018
I have the data as given. I need to fit a smooth curve through the data. The one I am getting right now for the second, third degree is relatively same(attached below). But I need one with a smooth curve. not the sharp turns. It doesn't matter if it passes through all the points or not. Any suggestions?
203.0173 -195.6477
275.3912 -244.2275
331.9024 -222.4161
387.4221 -173.8364

Accepted Answer

Birdman
Birdman on 31 Jan 2018
Edited: Birdman on 31 Jan 2018
Curve Fitting Tool should do it for you:
x=[203.0173 275.3912 331.9024 387.4221];
y=[-195.6477 -244.2275 -222.4161 -173.8364];
%%below from here requires and comes from Curve Fitting Toolbox
[xData, yData] = prepareCurveData( x, y );
ft = fittype( 'poly3' );
[fitresult, gof] = fit( xData, yData, ft );
figure( 'Name', 'Fitted Model' );
h = plot( fitresult, xData, yData );
legend( h, 'y vs. x', 'Fitted Model', 'Location', 'NorthEast' );
xlabel x
ylabel y
grid on
You can reach the fitted model(3rd in this case) by typing
fitresult

More Answers (0)

Categories

Find more on Curve Fitting Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!