Spring 2020 Assignment 10

From Course Wiki
Jump to: navigation, search

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.

  1. 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.
  2. 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.
  3. 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.

  1. Write a function to fit the Hog1 response to a sinusoid and extract the estimated amplitude and phase shift of the response signal. For each set of response data, make a plot showing the Hog1 response vs time and the best fit model function.
  2. Make a Bode plot (i.e. plot the amplitude and phase) of the Hog1-response as a function of frequency. Use log-log axes for the magnitude, and semi-log x axes for the phase. Since some frequencies have several measurements, you may either plot each fit result as a single point on the plot, or average the results together. For the phase plot, use wrapTo180 or wrapToPi to make sure your phase is in the appropriate range of angles.
  3. Qualitatively compare your Bode plot to the amplitude and phase found in the Mettetal paper. What aspects of the results are expected or unexpected? If your measurements do not agree, describe two or three reasons why they might differ.


Turn in all your MATLAB code in pdf format. No need to include functions that you used but did not modify.