Learn R Programming

SpecHelpers (version 0.2.7)

lorentzCurve: Compute a Lorentzian Curve

Description

Computes the y values describing a Lorentzian curve such as seen in an NMR peak. Requires a range of x values and parameters for peak position, area, and gamma (half the peak width at half-height).

Usage

lorentzCurve(x, x0, area, gamma)

Arguments

x

A vector of x values which will be used to compute the corresponding y values. Use enough to give good resolution.

x0

The position of the peak. Must fall in the range of x, of course.

area

The area of the peak, in arbitrary units.

gamma

HWHM, half-width at half-maximum. The peak "width" in units corresponding to x.

Value

A vector of y values corresponding to the x values supplied.

See Also

gaussCurve, makeSpec, plotNMRspec and plot2DNMRspec for drawing NMR spectra.

Examples

Run this code
# NOT RUN {
myx <- seq(0, 100, length.out = 1000) # use lots of point for resolution
myy <- lorentzCurve(x = myx, area = 1, x0 = 40, gamma = 5)
plot(myx, myy, type = "l", main = "Pure Lorentzian Curve")
y = 0.5*max(myy)
x = seq(40, 45, 0.5)
points(x = x, y = rep(y, length(x)), col = "blue", type = "l")
text(x = 42, y = y + 0.005, labels = c("gamma"), col = "blue", srt = 90)

# }

Run the code above in your browser using DataLab