How to get coefficients for second degree polynomial with only two given boundary conditions (means with two equations but with three coefficients)?
25 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have Energy displacement numeric data in which Energy follows second degree polynomial (Ax^2+Bx+C) as given below;
x (disp) = [ 0 1 2 3]; E (energy) = [0 1 4.5 10.5];
Consider first point x = 0 and 1, gives
0 = C1;
1 = A1+B1+C1;
Consider second point x = 1 and 2, gives
1 = A2+B2+C2;
4.5 = 4A2+2B2+C2;
But I have two equations with three coefficients, is there anyway numeric approximation method in matlab to solve for three coefficients with two equations?
0 Kommentare
Antworten (1)
David Goodmanson
am 9 Apr. 2022
Bearbeitet: David Goodmanson
am 9 Apr. 2022
Hi Ankit,
x = [ 0 1 2 3];
E = [0 1 4.5 10.5];
c = polyfit(x,E,2) % fit a quadratic
E1 = polyval(c,x)
figure(1)
plot(x,E,'o-',x,E1)
grid on
c =
1.2500 -0.2500 -0.0000
polyfit fits a quadratic (resulting coefficients are in c) to the four points in a least squared error sense. It so happens that the four points exactly fit the resulting quadratic.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Quadratic Programming and Cone Programming 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!