Compute polynomial coefficient with unequal vector?

Hello all, I have question about to compute polynomial coefficient with unequal number of membership of 2 vectors. If I have vector A as 10x1 and vector B as 7x1, can I possibly compute coefficient with order 4 of this 2 vectors? Thanks Ani.

2 件のコメント

KSSV
KSSV 2017 年 10 月 17 日
A fourth order polynomial has five unknowns..you have seven points known..you should be able to do it eh.
AniCnx
AniCnx 2017 年 10 月 17 日
On polyfit of matlab, it needs equally membership of vector A and B. Do it has any built in function of that problem?

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

 採用された回答

KSSV
KSSV 2017 年 10 月 17 日

1 投票

%%a random data
x = rand(10,1) ;
y = rand(7,1) ;
% sort x in ascending order and pick first seven
x = x(1:7) ;
%
[x,idx] = sort(x) ;
y = y(idx) ;
%%fit fourth order polymomial
[P,S] = polyfit(x,y,4) ;
x1 = linspace(min(x),max(x));
y1 = polyval(P,x1);
figure
plot(x,y,'-or')
hold on
plot(x1,y1)
hold off

3 件のコメント

AniCnx
AniCnx 2017 年 10 月 17 日
thank you very much, KSSV. I have some question from 'pick first seven', so that means it still need to be equal membership of the two vector, is that right? If I pick the last seven, coefficient will be changed from the first seven, am I corrected?
KSSV
KSSV 2017 年 10 月 17 日
Yes...
AniCnx
AniCnx 2017 年 10 月 17 日
Thank you very much, KSSV. May I ask one more question? That I have A=10x1, B=7x1. If I re-sampling B to be C=10x1. Coefficient of AB is equal or not equal to AC?

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

質問済み:

2017 年 10 月 17 日

コメント済み:

2017 年 10 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by