Curve fit for data points

6 Ansichten (letzte 30 Tage)
Michael Miller
Michael Miller am 12 Apr. 2020
Kommentiert: Michael Miller am 13 Apr. 2020
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 Kommentare
Michael Miller
Michael Miller am 12 Apr. 2020
Bearbeitet: Cris LaPierre am 13 Apr. 2020
%Inital Conditions
Fz_1100 = 1100;
Fz_880 = 880;
Fz_650 = 650;
Fz_430 = 430;
Fz_210 = 210;
% Pacejka coefficients for 1100 N
Dy_1100 = 2633;
Cy_1100 = 2.2136;
By_1100 = -0.1086;
Ey_1100 = -.3608;
Svy_1100 = -30.01;
% Pacejka coefficients for 880 N
Dy_880 = 2185;
Cy_880 = 2.139;
By_880 = -0.1193;
Ey_880 = 0.124;
Svy_880 = -29.52;
% Pacejka coefficients for 650 N
Dy_650 = 1721;
Cy_650 = 1.847;
By_650 = -0.1683;
Ey_650 = 0.3298;
Svy_650 = -29.02;
% Pacejka coefficients for 430 N
Dy_430 = 1212;
Cy_430 = 1.665;
By_430 = -0.1797;
Ey_430 = 0.3647;
Svy_430 = -26.3;
% Pacejka coefficients for 210 N
Dy_210 = 638.6;
Cy_210 = 1.604;
By_210 = -0.2165;
Ey_210 = 0.5203;
Svy_210 = -22.52;
I see what you are saying! Here is my data! I need a curve to fit those 5 data points. Therefore, when i hit run, a graph comes up with 5 points! i need a curve that fits them. I have 5 sets, but if i can do one i can do the rest. Hope that makes since.
Michael Miller
Michael Miller am 12 Apr. 2020
Also forgot to mention, the line needs to be linear!

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Cris LaPierre
Cris LaPierre am 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
  1 Kommentar
Michael Miller
Michael Miller am 13 Apr. 2020
wow! Didn't know you could do it like that! Thank you so much!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by