15.11.2014 Views

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Solving Linear Systems <strong>of</strong> Equations<br />

The preceding equation says that the vector y should be approximated by a<br />

linear combination <strong>of</strong> two other vectors, one the constant vector containing all<br />

ones and the other the vector with components e -t . The unknown coefficients,<br />

c 1 and c 2 , can be computed by doing a least squares fit, which minimizes the<br />

sum <strong>of</strong> the squares <strong>of</strong> the deviations <strong>of</strong> the data from the model. There are six<br />

equations in two unknowns, represented by the 6-by-2 matrix:<br />

E = [ones(size(t)) exp(-t)]<br />

E =<br />

1.0000 1.0000<br />

1.0000 0.7408<br />

1.0000 0.4493<br />

1.0000 0.3329<br />

1.0000 0.2019<br />

1.0000 0.1003<br />

Use the backslash operator to get the least squares solution:<br />

c = E\y<br />

c =<br />

0.4760<br />

0.3413<br />

In other words, the least squares fit to the data is<br />

yt () ≈ 0.4760 + 0.3413 e – t<br />

The following statements evaluate the model at regularly spaced increments in<br />

t, and then plot the result, together with the original data:<br />

T = (0:0.1:2.5)';<br />

Y = [ones(size(T)) exp(-T)]*c;<br />

plot(T,Y,'-',t,y,'o')<br />

You can see that E*c is not exactly equal to y, but that the difference might well<br />

be less than measurement errors in the original data.<br />

1-19

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!