Polyfit with other model

1 回表示 (過去 30 日間)
Adri Ann
Adri Ann 2020 年 8 月 3 日
編集済み: Bruno Luong 2020 年 8 月 3 日
Hi,
i am new here,
When i get it right polyfit is for polynomials like this: P(a) = c0 * a^0 + c1 * a^1 + c2 * a^2....
But how to get the coefficients from P(a) = 1 + c1 * a^1 + c^* a^2 .... So that the first value is fixed.
I only find this
Do I just have to subtract from A "1" and from the y too and that's it?
(A and y from the link)
greetings

回答 (1 件)

Bruno Luong
Bruno Luong 2020 年 8 月 3 日
編集済み: Bruno Luong 2020 年 8 月 3 日
Generate test data
x=linspace(0,1,100)
P = [rand(1,3) 1]
y=polyval(P,x) + 0.1*randn(size(x));
Fit polynomial (order n) y=P(x) assuming cst-term = 1.
n = 3;
M = x(:).^(n-1:-1:1);
P = [M\(y(:)-1); 1];
Check
plot(x,y,'.');
hold on
plot(x,polyval(P,x),'r');

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by