Filter löschen
Filter löschen

Polynomial Regression and finding Standard Error

4 Ansichten (letzte 30 Tage)
John wick
John wick am 9 Okt. 2019
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')

Antworten (1)

Duncan Carlsmith
Duncan Carlsmith am 16 Mai 2024

Kategorien

Mehr zu Polynomials finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by