%% Quiz 11 (Matlab) % %% Section 6.6, 8(a, b) x=[4;6;8;10;12;14;16;18]; y=[1.58;2.08;2.5;2.8;3.1;3.4;3.8;4.32]; % We'll label the "design matrix" X: X=[x, x.^2, x.^3]; B=inv(X'*X)*X'*y; B xx=linspace(min(x),max(x),200); yy=B(1)*xx+B(2)*xx.^2+B(3)*xx.^3; plot(x,y,'r^',xx,yy); %% Section 6.6, 11 theta=[0.88;1.10;1.42;1.77;2.14]; r=[3;2.3;1.65;1.25;1.01]; % Model equation is r = beta + eccent * (r * cos(theta)) % which is linear in beta and eccent: X=[ones(length(theta),1),r.*cos(theta)]; B=inv(X'*X)*X'*r; B beta=B(1); eccent=B(2); %Solve for r if theta=4.6: theta=4.6; R=beta/(1-eccent*cos(theta))