Es240_test2_solution_2_fall10-1

# Es240_test2_solution_2_fall10-1 - %Problem 2%Obtain a blank...

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

%Problem 2 %Obtain a blank slate clear all; close all; clc; x = [5 10 15 20 25 30 35 40 45 50] y = [17 24 31 33 37 37 40 40 42 41] %A. Linear transformations %a) employ transformations to linearize the data and use linear least-squares regression to fit the data into %i. a power model: yn = log(y); xn = log(x); p = polyfit(xn,yn,1) %linear coefficients obtained by MATLAB built-in ynest = polyval(p,xn); %predicted value for linear tranformation %Re-transforming to nonlinear b = p(1) a = exp(p(2)) %actual predicted y yestp = a*x.^b %ii. an exponential model %linear transformation lny = log(y) p = polyfit(x,lny,1) %linear coefficients obtained by MATLAB built-in lnyn = polyval(p,x); %predicted value for lineare tranformation %Re-transforming to nonlinear beta = p(1) %b = a1 alpha = exp(p(2)) %a = exp(a0) %actual predicted y yeste = alpha*exp(beta*x) %plotting the retransformed data figure plot(x,y,'g*', x, yestp,'m',x,yeste); title('Best fit line for re-transformed exponential model'); xlabel('x'); ylabel('y');

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 09/04/2011 for the course ENGINEERIN 240 taught by Professor Druche during the Spring '11 term at Montgomery College.

### Page1 / 3

Es240_test2_solution_2_fall10-1 - %Problem 2%Obtain a blank...

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

View Full Document
Ask a homework question - tutors are online