Next Spaceship

Driving into future…

Squares

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
clear;
%2008.4.30
t=[0.0;1.0;2.0;3.0;4.0;5.0];
y=[1.0;2.7;5.8;6.6;7.5;9.9];
n=5;
for i=1:6
    for j=0:n
        A(i,j+1)=t(i)^j;
    end
end
B=A'*A;
q=A'*y;
x=B\q;
syms b m;
b=0;
for i=1:n+1
   b=b+x(i)*m^(i-1);
end
m=-1:.05:6;
b=subs(b);
plot(t,y,'o',m,b);

Comments