MATLAB: Line plotting

plot

for yy = 1:length(overlap_peaks2)
x=overlap_peaks2(yy);
y=1:200000:1000000;
hold on;
plot(overlap_peaks2(yy),y, '-r')
end
length(overlap_peaks2) is just equal to 1
my question is why is it when i plot it, it shows up as seperate dots, how do i make it connect into a line? i am just tryign to plot x=589

Best Answer

for yy = 1:length(overlap_peaks2)
x=overlap_peaks2(yy);
y=1:200000:1000000;
hold on;
plot(repmat(x,1,length(y)),y, '-r')
end
By the way, you should also consider
for yy = 1:length(overlap_peaks2)
x=overlap_peaks2(yy);
hold on;
plot([x x],[1 1000000], '-r')
end
Related Question