Lab 4

Given a (plain text!) file containing

To do this, we need to know the name of the file, and how data is arranged in it, so need to open it in a (plain text!) editor.

Write a script "read.m" which:

To test and debug your code, create a "file.dat" with N=2 columns, each with 3 values ( so a 3×2 matrix ).

The first column should be sorted. You can just enter some numbers in "file.dat" in an editor.

Next, test it on a 4×3 array to make sure it also works. Insert brief comments to document what is being done.

To apply this on real data, I am providing a data file, produced by a code that implements a mathematical model for

It contains

labeled by column at the top ( x(i) C(i) B(i) etc). The last column is the index "i" of x(i).

Of main interest is the 3rd column, labeled "B(i)". It represents bacterial density at location x(i), at the output time

(normalized, B(i) means B(i)×10

at half-maximum height. Biologically, this is the width of the "band" the bacteria form during chemotaxis.

Download the file

The first two lines contain labels, need to be read over with

The rest of the lines are numerical values to be scanned into a matrix, say "mat".

You can see what the B-profile looks like easily in gnuplot:

Copy your "read.m" to "Lab4.m" and modify appropriately to achieve the following:

a. Read the data into a matrix "mat".

b. Extract each column into a vector (with sensible names: x , C , B , ... ). Only need x and B, so may extract only those.

c. Find

d. Plot B vs x and the line at height

The units of

e. Is this value of

(note that the "base" value of B is 1, not zero). Figure out a better expression for setting "cut".

f. Make sure your code runs and produces the plot.

( In the next lab, you'll incorporate finding FWHM into your code, see HW assignment. )

Then submit it via Canvas by the deadline.