Math 171 - Alexiades
Finding FWHM of a pulse
Pulses appear very often in many fields, expecially in biology, physics,
data processing, etc.
They often have a bell-like shape, a bump: the curve increases,
reaches a peak, then decreases towards some value.
A prime example is a "bell-curve", or "Gaussian", like:
G(x) = A exp( −(x−μ)2 / w2 )
, for some parameters A, μ, w.
The parameter w regulates the "width", how spread out the curve is.
Plot some examples
e.g. with A=1 , μ=1 , w=2 and w=3 , on same plot
(easy to do in gnuplot).
Clearly, A is the amplitude, and curve is symmetric about x=μ,
but w cannot be seen on the plot (w/√2 = σ=std deviation).
For such shapes, there are various ways of characterizing how "wide"
the pulse shape is.
One convenient, and commonly used way, is to determine the
Full Width at Half Maximum (FWHM).
If we know a formula for the curve y = F(x),
(as for a Gaussian y=G(x) above), then can find it exactly,
by intersecting y=F(x) with the horizontal line y=A/2,
"at half maximum" (half amplitude).
1. Find (the formula for) FWHM of a Gaussian y=G(x)
in terms of the parameters A, μ, w.
The amplitude of y=G(x) is A, so need to solve for x
the equation G(x) = A/2 .
But in general, only data values would be available, no formula, so
finding FWHM would need to be done numerically.
Think how FWHM can be found if we know only
N points of a quantity y = F(x),
(by reading the values from a data file, as in Lab4),
i.e. from the pairs (xi , yi), i=1:N,
which are stored in two arrays x and y.
2. Here is a strategy, write an algorithm for it, ON PAPER
• Need to find the maximum value M (height of the peak),
and the index where it occurs, call it ipeak ,
• Set the cutoff level at half maximum: cut = M/2.
• Find the first xi (before ipeak,
on the way up) at which yi ≥ cut.
Call it xLeft.
• Then find the first xi
(after ipeak, on the way down) at which
yi ≤ cut. Call it xRight.
• Then FWHM = xRight − xLeft .
3. Now implement the above algorithm
as a function FWHM = fwhm( x , y ),
which takes the arrays x , y and returns FWHM
(of the curve passing through the points).
4. Copy your Lab4.m file to Lab5.m ,
insert: % Name, Date, Lab5 ,
and modify it to do the following:
a. It reads the data file "prof300s.dat" and extracts arrays x and B , as was done in Lab4.
b. Instead of plotting (comment it out),
it calls the fwhm function to produce FWHM,
then prints it out nicely.
For convenience, insert the "fwhm" function at the bottom of Lab5.m
Make sure Lab5.m runs and prints out the FWHM of the y=B(x) curve.
Compare with the plot (produced in Lab4),
to see if it makes sense...
Then 'publish' it to produce "Lab5.pdf".
Check the .pdf: it should contain the Lab5.m code
(and the fwhm function),
and should show the value of FWHM it found at the end.
Submit Lab5.pdf on Canvas.