What's this discrete latch operation called?
I figured this out, it's called a Sample and Hold. The matlab page on it talks about how to implement one in matlab.

In summary, an interpolate function is used to create it. There are a couple of interpolate options, like "next", "previous" and "nearest". The "extrap" is needed to extrapolate the waveform for times 8 and 9. Continuing my example:

x     = [2,3,2,4]
t     = [1,3,4,7]
t_new = 1:9

x_new = interp1(t,x,t_new,"previous","extrap")


Produces

x_new =
     2   2   3   2   2   2   4   4   4