필터 지우기
필터 지우기

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개)

Duncan Carlsmith
Duncan Carlsmith 2024년 5월 16일

카테고리

Help CenterFile Exchange에서 Polynomials에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by