Polynomial Regression and finding Standard Error
조회 수: 15 (최근 30일)
이전 댓글 표시
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
2024년 5월 16일
The following shows how. https://www.mathworks.com/matlabcentral/fileexchange/165941-polynomial-fit-explorer
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Polynomials에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!