Vertical refline in matlab?

前端 未结 5 858
失恋的感觉
失恋的感觉 2020-12-19 23:12

How do I draw a vertical refline in matlab? e.g. I want to plot a line of x=5. Obviously using inf does not help at all. Can anyone give some advice?

5条回答
  •  有刺的猬
    2020-12-20 00:10

    You can create a vector with many identical values for x. Something like this:

    x = 5*ones(1,100);
    y = 1:100;
    plot(x,y)
    

    or use the line function:

    line([5,5],[0,10])
    

    To automatically detect the range of line, use ylim:

    plot(1:10)
    
    line([5,5],ylim)
    

提交回复
热议问题