MATLAB: MATLAB — how to create a parabolic arc

arcsMATLABparabolicsimpsons rule

Example, I have three points x1, x2, and x3.
x1 is the start point of the arc; x3 is the end point of the arc; x2 is the critical point of the arc (where the tangent slope is zero).
If x2<x1, then the arc is a U-shaped (smiley); If x2>x1, then the arc is a upside-down-U-shaped (upside smiley).
Any ideas?

Best Answer

hi,
The parabola's equation is defined y=ax²+bx+c, you need to set the coefficients a,b,and c so as the line passes through the three points x1,x2 and x3 :
x1=[0,0];
x2=[5,5];
x3=[10,0];
Y=[x1(2);x2(2);x3(2)]
A=[x1(1)^2 x1(1) 1;x2(1)^2 x2(1) 1;x3(1)^2 x3(1) 1]
X=inv(A)*Y
x=x1(1):0.1:x3(1);
Y=X(1)*x.^2+X(2)*x;
figure, plot(x,Y), grid on,
hold on
text(x1(1),x1(2), ' POINT X1')
text(x2(1),x2(2), ' POINT X2')
text(x3(1),x3(2), ' POINT X3')
hold off
Related Question