diary20050211

diary20050211 - x fx = polyval(p,x) plot(x,fx,'r') A A = [...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
% Matlab diary from cs110a, Feb 11 2005. % % This is what I typed in class. % % Type it into Matlab yourself to % reproduce the output I showed. load censusdata whos t y plot(t,y,'o') interpgui(t,y) plot(t,y,'o') clc y n = length(y) A = [t ones(n,1)] p = [1 ; 1] A*p - y norm(ans) p = [2;1] norm(A*p-y) p = A \ y norm(A*p - y) hold on x = [1880 : 10 : 2020] fx = p(1)*x + p(2) plot(x,fx) A t .* t A = [t .* t, t, ones(n,1)] p = A \ y p(1) p(2) p(3)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: x fx = polyval(p,x) plot(x,fx,'r') A A = [ t.*t.*t , t.*t, t, ones(n,1)] p = A \y Warning: Rank deficient, rank = 3, tol = 6.0185e-005. cond(A) A = [t .* t, t, ones(n,1)] cond(A) A = [t ones(n,1)] cond(A) A = [ t.*t.*t , t.*t, t, ones(n,1)] cond(A) s = (t-1950) / 50 A = [ s.*s.*s , s.*s, s, ones(n,1)] cond(A) p = A \ y x fx = polyval(p, (x-1950)/50) plot(x,fx,'g') censusgui...
View Full Document

Ask a homework question - tutors are online