Escolar Documentos
Profissional Documentos
Cultura Documentos
[]
x1 1
x2 1
X= . . ; Y =
. .
. .
xn 1
[]
y1
y2
a
;
C=
b
.
c
.
yn
C=(X t . X ) 1 .( X t . Y )
[]
1
1
1
1
1
1
1
1
Y=y
Y=
10
9
7
5
4
3
0
-1
C = (X'*X)\(X'*Y)
C=
-1.6408
8.3169
plot(x,y,'*b'),grid
hold on
t = min(x):0.01:max(x);
f = polyval(C,t);
plot(t,f,'r'),grid
Exemplo 2
x = [-3 0 2 4]'
y = [3 1 1 3]'
plot(x,y,'*b'),grid, hold on
X = [x.^2 x x.^0] = estou transformando num polinmio de grau 2. J que uma parbola.
X=
9 -3
0 0
4 2
16 4
1
1
1
1
C = (X'*X)\(X'*Y)
C=
0.1785
-0.1925
0.8505
t = min(x):0.01:max(x);
f = polyval(C,t);
ento
f(x) = 0.1785x^2-0.1925x + 0.8505
plot(t,f,'r'),grid