find the coefficients a, b, and c of the quadratic polynomial. that passes through the three points (x, y)

93 ビュー (過去 30 日間)
find the coefficients a, b, and c of the quadratic polynomial y = ax^2+ bx + c that passes through the three points (x, y) = (1, 4), (4, 73), (5, 120)
I am not sure how to go code this problem and need help!!

回答 (4 件)

KSSV
KSSV 2022 年 4 月 12 日
% Convert the equation to form Ax = b
P = [1, 4 ;4, 73; 5, 120] ; % points
x = P(:,1) ;
y = P(:,2) ;
b = P(:,2) ; % RHS
A = [x.^2 x repelem(1,3,1)] ;
% solve
x = A\b ;
% check
A*x
ans = 3×1
4.0000 73.0000 120.0000

KALYAN ACHARJYA
KALYAN ACHARJYA 2022 年 4 月 12 日
編集済み: KALYAN ACHARJYA 2022 年 4 月 12 日
Sufficients Hints:
As it is the part of your work, please check the hints below, the equation is y = ax^2+ bx + c with three given Points.
Step 1:
Subsititute all those three points in the eqaution, you will get the three eqaution with unknown a,b,c
Step 2:
Create an Augumented Matrix using step 1 (3 equations)
Step 3:
Solve it for a,b,c
Helpful links
Do it yourself is the best way of learning!
Hope it helps!
  3 件のコメント
Sabrina Lozano
Sabrina Lozano 2022 年 4 月 12 日
clc; close all;
A=[1 1 1 4;64 16 4 73;125 25 5 120]
rref(A)
ans =
1.0000 0 0 0.2500
0 1.0000 0 3.5000
0 0 1.0000 0.2500
% would this be correct ??
Sabrina Lozano
Sabrina Lozano 2022 年 4 月 12 日
This code was for a cubic polynomial

サインインしてコメントする。


VBBV
VBBV 2022 年 4 月 12 日
syms a b c
x = [1 4 5];
y = [4 73 120];
eqn = y == a*x.^2+b*x+c
eqn = 
sol = solve(eqn,[a b c])
sol = struct with fields:
a: 6 b: -7 c: 5
  4 件のコメント
DGM
DGM 2022 年 4 月 12 日
You need to have the Symbolic Math toolbox to use syms.
Sabrina Lozano
Sabrina Lozano 2022 年 4 月 12 日
ah okay I only have the signal processing tool box.

サインインしてコメントする。


Sam Chak
Sam Chak 2022 年 4 月 12 日
編集済み: Sam Chak 2022 年 4 月 12 日
This problem can be rather easily solved with Curve-Fitting Toolbox with a click of a button or one simple function:
p = polyfit(x, y, 2)
However, I believe this is not the result your Professor wants to see. She or he probably wants to look at your efforts in computing the code according to what is taught in her or his lecture.
I'd suggest you to use a spreadsheet to tabulate out the necessary computations to be performed on the three points
Then, compose this:
which exactly a linear system
.
The solution is given by
which is easily computed in MATLAB without using the Curve-Fitting Toolbox
x = A\b
But you may lose some marks for not computing the inverse of matrix A manually that involves calculating the determinant. Better check with your Professor if computing the matrix inverse is necessary shown in the working.
Don't worry about being discovered by your Professor as these are merely guidelines from the textbook or public domain knowledge. You just have to compute the required items as shown above.
Hope this explanation is helpful for you to discover your learning experience as mentioned @KALYAN ACHARJYA.
  1 件のコメント
Sabrina Lozano
Sabrina Lozano 2022 年 4 月 12 日
Thank you very much this explanation was very helpfull !!! This is my fisrt class using matlab im still tryin to learn the basics!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by