Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
23 lines (17 sloc) 459 Bytes
clear
clc
% part a
xa=[1 2 3 4 5]';
ya=[2.2 2.8 3.6 4.5 5.5]';
Za = [ones(size(xa)), xa, xa.^-1];
[a1,fx1,r2_1] = least_squares(Za,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]';
Zb = [ones(size(xb)), xb, xb.^2, xb.^3];
[a2,fx2,r2_2] = least_squares(Zb,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]';
Zc = [exp(-1.5*xc),exp(-0.3*xc), exp(-0.05*xc)];
[a3,fx3,r2_3] = least_squares(Zc,yc);
You can’t perform that action at this time.