如何在Matlab中绘制一条垂直线?

时间:2019-03-26 10:27:13

标签: matlab plot

theta = linspace(0,2*pi,200); y = theta;x = 10;plot(x,y,'o');

当我写这篇文章时,我得到了点,但是当我用plot(x,y)替换plot(x,y,'o')时,我应该在x = 4处得到一条垂直线,但是图形变为空。 / p>

2 个答案:

答案 0 :(得分:2)

您可以使用stem

x = 10;
y = 200;
stem(x,y,'Marker','none');

stem plot

答案 1 :(得分:1)

从此答案开始:https://it.mathworks.com/matlabcentral/answers/2031-adding-vertical-line-to-plot

fig=figure; 
hax=axes; 
x=0:0.1:10; 
hold on 
plot(x,sin(x)) 
SP=1; %your point goes here 
line([SP SP],get(hax,'YLim'),'Color',[1 0 0])