I am trying to plot some one-dimensional data onto a 2-D plot in MATLAB.
Basically, I have a waveform output and I would like to have vertical lines superposed at relevant data points. At the moment, I am plotting on top of my pre-existing figure with the following code:
plot(velocityPeaks(:,1), 0, 'r.');
This produces a red dot at y = 0 for each of the positions that ‘velocityPeaks’ contains a value. I’d prefer to have this as a vertical red line that cuts through the whole graph. Here is my current output:

Those red dots – at the moment I have to use a ruler against the computer screen to see exactly what they relate to. Not the ideal solution!
This should work:
This will plot a series of vertical lines at the locations of
velocityPeaks(:,1)at the y limits already contained in the plot. To specify the limit yourself, use, for example: