# Lab12 - Riti Gupta/20249537 Section 22/Lab12 1 > plot(time...

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

Riti Gupta/20249537 Section 22/Lab12 1. >> plot(time, temp, '.') >> title('Steamboat Geyser') >> xlabel('time') >> ylabel('Temp (degrees Celsius)') 2. function [coeff, fit] = polyreg(x, y, deg) if length(x) == length(y) A = ones(length(x),1); for i=1:deg A(:,i+1) = x.^i; end coeff = inv(A'*A)*A'*y fit = A*coeff end 3. >> [coeff, fit] = polyreg(time, temp, 1); >> x=0:.01:14.3899; >> y=coeff(1)+coeff(2)*x; >> plot(time,temp, 'g.',x,y,'b') 0 5 10 15 15 20 25 30 35 40 45 50 55 60 65 Steamboat Geyser time (sec) Temp (degrees Celsius)

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

View Full Document
>> legend('original data', 'best fit line') >> title('Best Fit Line for Temperature') >> xlabel('time') >> ylabel('Temp (C)') From the best fit line, you can determine that as time increases, the temperature of the geyser decreases. 4. >> [coeff, fit] = polyreg(time, temp, 2); >> x=0:.01:14.3899; >> y=coeff(1)+coeff(2)*x+coeff(3)*x.^2; >> plot(time,temp, 'g.',x,y,'b') >> legend('original data', 'best quad fit’) >> title('Best Fit Line for Temperature') >> xlabel('time') >> ylabel('Temp (C)')
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 8

Lab12 - Riti Gupta/20249537 Section 22/Lab12 1 > plot(time...

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

View Full Document
Ask a homework question - tutors are online