Cody

# Problem 42840. Coefficients and vertex of a parabola given 3 points

Solution 1899057

Submitted on 13 Aug 2019
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
P1 = [1 0]; P2 = [2 5]; P3 = [-1 2]; abc = [2 -1 -1]; O1 = Para3(P1,P2,P3); assert(isequal(O1,abc))

Error using polyfit (line 44) X and Y vectors must be the same size. Error in Para3 (line 2) Coeff = polyfit([P(1),Q(1),R(1)],[P,Q,R],2); Error in Test1 (line 3) O1 = Para3(P1,P2,P3);

2   Fail
P1 = [1 0]; P2 = [2 5]; P3 = [-1 2]; vxvy = [0.25 -1.125]; [~,O2] = Para3(P1,P2,P3); assert(isequal(O2,vxvy))

Error using polyfit (line 44) X and Y vectors must be the same size. Error in Para3 (line 2) Coeff = polyfit([P(1),Q(1),R(1)],[P,Q,R],2); Error in Test2 (line 3) [~,O2] = Para3(P1,P2,P3);

3   Fail
i = [0 0]; j = [1 1]; k = [-1 1]; abc = [1 0 0]; tip = [0 0]; [Res,Ans] = Para3(i,j,k); assert(isequal(Res,abc)) assert(isequal(Ans,tip))

Error using polyfit (line 44) X and Y vectors must be the same size. Error in Para3 (line 2) Coeff = polyfit([P(1),Q(1),R(1)],[P,Q,R],2); Error in Test3 (line 4) [Res,Ans] = Para3(i,j,k);

4   Fail
ptA = [-1 -5]; ptB = [2 4]; ptC = [3 -5]; exp1 = [-3 6 4]; exp2 = [1 7]; [coefficients,vertex] = Para3(ptA,ptB,ptC); assert(isequal(exp1,coefficients)) assert(isequal(exp2,vertex))

Error using polyfit (line 44) X and Y vectors must be the same size. Error in Para3 (line 2) Coeff = polyfit([P(1),Q(1),R(1)],[P,Q,R],2); Error in Test4 (line 4) [coefficients,vertex] = Para3(ptA,ptB,ptC);