Skip to content
Permalink
d2e428c722
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
12 lines (11 sloc) 441 Bytes
%----Calculation of 1b.----------------------------
%Z matrix calculation altered to best fit polynomial
x = [3 4 5 7 8 9 11 12]';
y = [1.6 3.6 4.4 3.4 2.2 2.8 3.8 4.6]';
Z = [x.^0 x.^1 x.^2 x.^3]; %Compute Z matrix (from book)
[a, fx, r_2] = linear_squares(Z,y) %apply to linear_squares.m
x_fn = linspace(min(x),max(x));
plot(x,y,'o', x_fn, a(1)+a(2)*x_fn.^1+a(3)*x_fn.^2+a(4)*x_fn.^3);
title('Best fit case B');
xlabel('x');
ylabel('y');