%% Homework 6
%% Due Monday, February 28 before 5:00pm
% Use [Live Editor > Save > Export to PDF] to prepare your submission for Gradescope.
% This assignment uses data from the MAT file HW6_data.mat. Download this file and run

load HW6_data.mat

% to load variables x, y, blood, and ecm into the workspace.
%% Part 1: Polynomial Fitting
% Variables x and y contain 12 values from an unknown cubic polynomial, i.e.
% y = \beta_0+\beta_1x+\beta_2x^2+\beta_3x^3
% Using the values x and y, compute estimates for parameters \beta_0, \ldots, \beta_3 using linear regression. For this problem, you are not allowed to use fitlm, regress, polyfit, or any other linear regression or curve fitting tools. You must construct the design matrix and calculate parameter estimates via pseudoinversion.

% place your code here

% Using your parameter estimates, plot the points in variables x and y and a line corresponding to the best fit polynomial. Both the points and the line should be on the same plot.

% place your code here

%% Part 2: Cell Growth
% Variables t and cells contain six cell counts for dividing mammalian cells in a culture dish. (The times in t are in hours.) Your task is to find the exponential growth rate of the cells using linear regression. For this problem, you are not allowed to use fitlm, regress, polyfit, or any other linear regression or curve fitting tools.
% a.) Plot the number of cells over time.

% place your code here

% b.) Set up a design matrix for the linearized exponential growth equation from section 9.4.

% place your code here

% c.) Calculate the pseudoinverse of the design matrix and use it to fit your model.

% place your code here

% d.) Calculate the exponential growth rate of the cells. What are the units?
% <place your answer here>
% e.) Use the fitted parameters to find the inital number of cells. How does this value compare with the number of cells at t = 0 h in your data?
% <place your answer here>