Skip to content
Permalink
bf055a4ea9
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
18 lines (15 sloc) 455 Bytes
% part a
xa=[1 2 3 4 5]';
ya=[2.2 2.8 3.6 4.5 5.5]';
Z=[ones(size(xa)) xa xa.^1];
[ a, fx, r2 ] = least_squares( Z, ya );
% part b
xb=[3 4 5 7 8 9 11 12]';
yb=[1.6 3.6 4.4 3.4 2.2 2.8 3.8 4.6]';
Z=[ones(size(xb)) xb xb.^2 xb.^3];
[ a, fx, r2 ] = least_squares( Z, yb );
% part c
xc=[0.5 1 2 3 4 5 6 7 9]';
yc=[6 4.4 3.2 2.7 2.2 1.9 1.7 1.4 1.1]';
Z=[exp(-1.5*xc), exp(-.3*xc),exp(-.05*xc)];
[ a3, fx3, r23 ] = least_squares( Z, yc );