Spring 2020 Assignment 10
In this assignment, you will find the amplitude and phase response of Hog1 to osmotic shock using student data from last semester. Note that this assignment is OPTIONAL, and completing it will give you +2 points of extra credit on a previous assignment.
- Start by downloading the file fall2019_StudentData_Responses.mat from the course dropbox, and load the data into matlab. You should see that this file contains two variables:
- allClassResponseData is a cell array containing the analyzed response data from each group. Each element of the cell array is a 3-column matrix containing the response data. The columns represent (in order): the time (in seconds), the mean response (the average correlation between GFP and RFP in each cell), and the standard error of the response. To access the matrix of the iith group, you can use curly braces: allClassResponseData{ii}.
- allClassOscillationPeriods is a vector containing the oscillation period (in seconds) for each of the elements in allClassResponseData.
- For each set of data in allClassResponseData, use nlinfit to fit a sine function to extract the amplitude and phase of the response at that input frequency.
- Remember that nlinfit requires four inputs in this order: the independent variable (time), the dependent variable (hog1 response), a model function (more about this below), and a vector containing initial guesses for each parameter.
- Your model function should be a sine wave with an amplitude, phase, and offset as fit parameters. The offset is required because the data is not centered around zero. Additionally, you may consider adding a decreasing slope to your offset (i.e. offset = A – Bt) to help correct for some experimental artifacts (like the cells going out of focus). The frequency of oscillations of interest is determined by our experiment (given by 1./allClassOscillationPeriods), and should be fixed rather than left as a fit parameter.
- Plot the best-fit amplitude and phase in a Bode plot.
Tip #1: Test your code for a single data set before looping through the entire cell array.
Tip #2: The model function used by nlinfit needs to have the vector of parameters as its first argument, and the independent variable as its second argument. You may find the following template useful for the model function:
exampleModelFunction = @(p,t) p(1) * t.^2 + p(2) * t + p(3) t^3; bestFitParameters = nlinfit( time, response, exampleModelFunction, [1 2 3]);
This is an example of the model function $ y = a t^2 + b t +c $, where a, b, and c are fit parameters with initial guesses a = 1, b = 2, and c =3.
Turn in all your MATLAB code in pdf format. No need to include functions that you used but did not modify. |