P14_14 - %saturation % invx = 1./x; i invy = 1./y; i A3 =...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
%Problem 14.14 % function P14_14 f x = [5 10 15 20 25 30 35 40 45 50]; x y = [17 24 31 33 37 37 40 40 42 41]; y X = (0:1:60)'; X %---------------------------------------------------------------------- %linear % A1 = [ones(10,1) x']; A b1 = [y']; b coefs1 = A1\b1; c a0lin = coefs1(1,1) a a1lin = coefs1(2,1) a Flin = a0lin + a1lin*X; F %plot(x, y, 'o', X, Flin) % Sr1 = sum((y - (a0lin + a1lin*x)).^2); S St1 = sum((y - mean(y)).^2); S r2lin = (St1-Sr1)/St1 r %----------------------------------------------------------------------- % %power % logx = log10(x); l logy = log10(y); l A2 = [ones(10,1) logx']; A b2 = [logy']; b coefs2 = A2\b2; c a0pow = 10^coefs2(1,1) a a1pow = coefs2(2,1) a Fpow = a0pow.*X.^a1pow; F %plot(x, y, 'o', X, Fpow) % Sr2 = sum((y - a0pow.*x.^a1pow).^2); S St2 = sum((y - mean(y)).^2); S
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
r2pow = (St2-Sr2)/St2 r %--------------------------------------------------------------------
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %saturation % invx = 1./x; i invy = 1./y; i A3 = [ones(10,1) invx']; A b3 = [invy']; b coefs3 = A3\b3; c a0sat = 1/coefs3(1,1) a a1sat = a0sat*coefs3(2,1) a Fsat = (a0sat.*X)./(X + a1sat); F %plot(x, y, 'o', X, Fsat) % Sr3 = sum((y - (a0sat.*x)./(x + a1sat)).^2); S St3 = sum((y - mean(y)).^2); S r2sat = (St3 - Sr3)/St3 r %----------------------------------------------------------------------% %quadratic % x2 = x.^2; x A4 = [ones(10,1) x' x2']; A b4 = [y']; b coefs4 = A4\b4; c a0quad = coefs4(1,1) a a1quad = coefs4(2,1) a a2quad = coefs4(3,1) a Fquad = a0quad + a1quad.*X + a2quad*X.^2; F %plot(x, y, 'o', X, Fquad) % Sr4 = sum((y - (a0quad + a1quad.*x + a2quad*x.^2)).^2); S St4 = sum((y - mean(y)).^2); S r2quad = (St4 - Sr4)/St4 r r...
View Full Document

Page1 / 3

P14_14 - %saturation % invx = 1./x; i invy = 1./y; i A3 =...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online