How to find coefficients of a polynomial using Matlab?

17 visualizaciones (últimos 30 días)
Cheri Ko
Cheri Ko el 21 de Abr. de 2018
Respondida: AMIR AZMI ABD RAHMAN el 7 de Dic. de 2020
Hi, how can I write the code for the following question: Given the cubic polynomial p(x)=c1+c2x+c3x^2+c4x^3 with a prescribed behaviour:p(x k)=y k, for k=1,2,3,4 In addition; 1) n is an integer parameter. 2) a matrix M will be generated by the value of the parameter n. The matrix M will have size 2×4. The entries of M are given by M(1,k)=x k and M(2,k)=y k for k=1,2,3,4.
How could I use Matlab to Create 4×1 column vector v=[c1,c2,c3,c4] (where c1,c2,c3 and c4 are the coefficients of the polynomial p(x))?
Thanks!

Respuestas (2)

Ameer Hamza
Ameer Hamza el 21 de Abr. de 2018

For a given matrix M you can use the following command to find coefficients vector v.

v = polyfit(M(1,:), M(2,:));

This will return coefficients as v = [c4 c3 c2 c1]. You can reverse the coefficient vector as

v = fliplr(v);

to get vector is the required order.


AMIR AZMI ABD RAHMAN
AMIR AZMI ABD RAHMAN el 7 de Dic. de 2020
hi cheri can i see ur programs

Categorías

Más información sobre Polynomials en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by