convspec

Convolute spectrum with line shape.

Syntax
out = convspec(spec,df,fwhm)
out = convspec(spec,df,fwhm,deriv)
out = convspec(spec,df,fwhm,deriv,alpha)
out = convspec(spec,df,fwhm,deriv,alpha,phase)
Description

Convolutes the (real or complex) spectral data array spec with a line shape. df specifies the abscissa step, i.e. the frequency or field increment from one point to the next in spec. fwhm is the FWHM of the line shape in the same units as df.

The rest of the parameters is identical to those of lshape. deriv indicates the derivative, 0 being the default. alpha determines the line shape function, alpha = 1 is a pure Gaussian (the default) and alpha = 0 is a pure Lorentzian.

phase determines the phase of the Lorentzian component, 0 being pure absorption and pi/2 pure dispersion.

out is the convoluted spectrum, exactly the same size as spec. The applied line shape is normalized in a way that it does not change the integral of the spectrum.

If spec is more than 1D, convspec operates on all non-singleton dimensions. It is possible to define different parameters for each dimension. For 2D, e.g. df = 2 means that the abscissa step is 2 for both dimensions. df = [2 3] means it is 2 for the first and 3 for the second dimension. The parameters fwhm, deriv and alpha work the same way. If fwhm(i) = 0, convolution along dimension i is skipped.

Examples

To convolute a 1D spectrum with a Lorentzian first derivative use

spec = zeros(1,1024); spec([70 400 560]) = [3  6  7];
w = convspec(spec,1,30,1,0);
plot(w);

In the 2D case, one can use different line widths for the 2 dimensions.

spec = zeros(128); spec(70,70) = 3; spec(100,50) = 1;
w = convspec(spec,1,[20 10]);
pcolor(w);

The line shape is the default, a Gaussian, in both dimensions.

To achieve convolution only along the second dimension, set fwhm for the other dimension to zero.

w = convspec(spec,1,[0 10]);
pcolor(w);
Algorithm

The convolution is performed in the inverse domain, by multiplying the inverse FFT of both the spectral array and the full line shape array followed by FFT. To avoid fold-around for peaks at the edges, each dimension is temporarily padded at both ends.

For arrays with more than two dimensions, the convolution can get very time-consuming.

See also

gaussian, lorentzian, lshape, voigtian