How to simulate a Lorentzian broadened spectrum in MATLAB? I'm trying to simulate the 2nu2 band of HCN in MATLAB. I generate a stick spectrum from the data I have (taken from the HITRAN database) and then use conv() to apply my line shape function. However, when I plot the data, the broadened spectrum does not line up with the stick spectrum at all. I cannot figure out what it is that I'm doing wrong or what I need to change to align the spectra. Does anyone know what is I need to fix or a resource I could use to solve this issue?
This is the spectrum I've simulated:

and the function I use to generate the spectrum is
function f = func()
HCN2nu2 = importdata('I:/HCN 2nu2.txt');
HCN = HCN2nu2(1:111,1:2);
AX = HCN2nu2(1:111,2);
v = [];
s = [];
L = [];
q = 1;
p = HCN(q);
increase = false;
for i = 6200:0.01:6700
    for x = 1:111
        if i == round(HCN(x,1), 2)
            z = AX(x);
            increase = true;
            break
        else
            z = 0;
        end
    end
    v = [v; i];
    s = [s; z];
    if increase == true
        q = q + 1;
        increase = false;
        if q &gt; 111
            q = 111;
        end
    end
    t = (1/(1 + ((i - p)/0.5)^2));
    L = [L; t];
end
hold on
plot(v,s)
k = conv(L,s, 'same');
plot(v,k)
ylim([0 8e-21]);
hold off
end

Any help would be greatly appreciated
Link to the data file used to generate this spectrum:
https://github.com/tkh97/HCN-2nu2.git
Update : In the given data by the OP, the x scale is not evenly spaced so the discrete convolution approach will not work to generate a spectrum until and unless your data is evenly spaced! The trick mentioned by EdV is a very nice shortcut. Here, if you really want to play around with convolution via MATLAB, then read below.
Solution: You can satisfy yourself as follows:

Make sure you have a even spacing of the x-axis. Your uneven axis threw me off, and it took a while to discover why it is not working. I wish you mentioned it earlier.
Your sticks are basically scaled delta functions as Prof. Ed said.
Generate a vector for a single Lorentzian peak, whose center is zero, which is also evenly spaced. The x-axis of the Lorentzian would be symmetric [-length (wavenumber/2):Sampling rate:length(wavenumber/2)-Sampling rate].
Perform convolution of your spectrum and this Lorentzian.

Let us start with a Dirac delta centered at point $x.$ I don't know how to draw a displace Dirac delta in MATLAB. I manually made it in an Excel file. If you convolute it with a zero centered Lorentzian, then you will get a Lorentzian centered at $x.$ This is called the sifting property.
Basically, all you have to ensure is that your Lorentzian is centered at zero. First, play with convolution using single stick. Once you correct the code, so that the line position does not change, apply it on the entire spectrum.

A great book is Bracewell's Fourier Transform And Its Applications. It is all there. From MIT 2.14 / 2.140 Analysis and Design of Feedback Control Systems, Spring 2007 handout:

1.1 The “Sifting” Property of the Impulse
When an impulse appears in a product within an integrand, it has the property of ”sifting” out the value of the integrand at the point of its occurrence:
$$\int_{-\infty}^\infty f(t)δ(t - a)\,\mathrm dt = f(a)\tag{5}$$
This is easily seen by noting that $δ(t − a)$ is zero except at $t = a,$ and for its infinitesimal duration $f(t)$ may be considered a constant and taken outside the integral, so that
$$\int_{-\infty}^\infty f(t)δ(t - a)\,\mathrm dt = f(a)\int_{-\infty}^\infty δ(t - a)\,\mathrm dt = f(a)\tag{6}$$
from the unit area property.