- When you say "5 data points", do you actually mean the 5 sets of data in your 5 plots?
- Do you want to fit a single curve that fits all 5 sets of data, or 5 curves (one for each set)?
- If you want 5 curves, are there any shared parameters?
- What kind of curve? Polynomial? What order polynomial?
- What's the relationship, if any, among the 5 sets of data?
Curve fit for data points
10 views (last 30 days)
Show older comments
Here is my code and im trying to curve fit the 5 data points and im having a hard time because they are all seperate!
figure(5)
plot(Fz_1100,Svy_1100)
scatter(Fz_1100,Svy_1100,'k');
hold on
plot(Fz_880,Svy_880)
scatter(Fz_880,Svy_880,'b');
hold on
plot(Fz_650,Svy_650)
scatter(Fz_650,Svy_650,'g');
hold on
plot(Fz_430,Svy_430)
scatter(Fz_430,Svy_430,'m');
hold on
plot(Fz_210,Svy_210)
scatter(Fz_210,Svy_210,'r');
hold on
4 Comments
Answers (1)
Cris LaPierre
on 13 Apr 2020
Here's how I would do it.
Fz = [Fz_1100 Fz_880 Fz_650 Fz_430 Fz_210];
Dy = [Dy_1100 Dy_880 Dy_650 Dy_430 Dy_210];
Cy = [Cy_1100 Cy_880 Cy_650 Cy_430 Cy_210];
By = [By_1100 By_880 By_650 By_430 By_210];
Ey = [Ey_1100 Ey_880 Ey_650 Ey_430 Ey_210];
Svy = [Svy_1100 Svy_880 Svy_650 Svy_430 Svy_210];
% Just show Svy
scatter(Fz,Svy,'k')
% fit Svy to a first order polynomial (y=m*x+b)
p=polyfit(Fz,Svy,1);
% Calculate Y values of fit line
fitY = polyval(p,Fz);
hold on
plot(Fz,fitY)
hold off
See Also
Categories
Find more on Get Started with 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!