How can I make a quadratic approximation given two points and incidence angle at the second point?

I'm trying to make a parabolic equation that will run through two given points, and with given incidence angle at the 2nd point.

Answers (1)

Maybe something like this is what you need? (assuming by "incidence angle" you mean slope)
% Construct some sample data for y = a*x^2 + b*x + c
a = 2;
b = 3;
c = -4;
p = [a b c];
point1 = [-2 polyval(p,-2)]; % (x1,y1)
point2 = [ 3 polyval(p, 3)]; % (x2,y2)
slope2 = polyval(polyder(p),3); % slope at x2
% Form the Ax=B from these equations:
%
% a*x1^2 + b*x1 + c = y1
% a*x2^2 + b*x2 + c = y2
% 2*a*x2 + b = slope2
%
% Yields this 3x3 * 3x1 = 3x1 linear set of equations in a,b,c
%
% [ x1^2 x1 1 ] [a] [y1]
% [ x2^2 x2 1 ] * [b] = [y2]
% [ 2*x2 1 0 ] [c] [slope2]
%
% Then just use backslash to solve for the coefficients
A = [point1(1)^2 point1(1) 1;
point2(1)^2 point2(1) 1;
2*point2(1) 1 0];
B = [point1(2);
point2(2);
slope2];
% Solve for the coefficients of the polynomial
coeff = A\B;
The values in coeff should match the original a, b, c coefficients.

Categories

Asked:

on 25 Feb 2018

Answered:

on 26 Feb 2018

Community Treasure Hunt

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

Start Hunting!