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

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

%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

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

View Full Document
r2pow = (St2-Sr2)/St2 r %--------------------------------------------------------------------
This is the end of the preview. Sign up to access the rest of the document.