MATLAB: Plot all positions in a vector a fixed length line

plotvector

Hi.
I have a vector of x values. On an image, I want to plot a vertical line at each of the x values (xpeak). The vertical centre of each line should be at yy so the length of the lines is y-5 to y+5.
I tried the following but got an error. (Vectors must be the same length)
plot([xpeak xpeak],[yy-5 yy+5],'y')
Is there a way to do this without using a for loop? Thanks

Best Answer

Use semicolon between the vectors and make sure they are row vectors. [xpeaks;xpeaks]