フィルターのクリア

Polynomial Regression and finding Standard Error

4 ビュー (過去 30 日間)
John wick
John wick 2019 年 10 月 9 日
回答済み: Duncan Carlsmith 2024 年 5 月 16 日
Assign 1.jpg
Please help me double check my work here ♥
x = [-4 7 -5 -9 2 -6 1 10];
y = [13 -3 -16 -19 -12 1 9 -5];
c1 = [length(x) sum(x) sum(x.^2) sum(x.^3) sum(x.^4) sum(x.^5)]';
c2 = [sum(x) sum(x.^2) sum(x.^3) sum(x.^4) sum(x.^5) sum(x.^6)]';
c3 = [sum(x.^2) sum(x.^3) sum(x.^4) sum(x.^5) sum(x.^6) sum(x.^7)]';
c4 = [sum(x.^3) sum(x.^4) sum(x.^5) sum(x.^6) sum(x.^7) sum(x.^8)]';
c5 = [sum(x.^4) sum(x.^5) sum(x.^6) sum(x.^7) sum(x.^8) sum(x.^9)]';
c6 = [sum(x.^5) sum(x.^6) sum(x.^7) sum(x.^8) sum(x.^9) sum(x.^10)]';
N = [c1 c2 c3 c4 c5 c6]
r = [sum(y) sum(x.*y) sum(x.^2.*y) sum(x.^3.*y) sum(x.^4.*y) sum(x.^5.*y)]'
%Solve
a = N\r
%Plotting
xx = linspace(-9,10,500);
yy = polyval(flipud(a),xx);
plot(x,y,'or',xx,yy,'-b')
  1 件のコメント
John wick
John wick 2019 年 10 月 9 日
My graph would be like this graph Assign 1.jpg

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

回答 (1 件)

Duncan Carlsmith
Duncan Carlsmith 2024 年 5 月 16 日

カテゴリ

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