Matlab:由vector指定的x值的垂直线(Matlab: vertical lines at x-values specified by vector)
我有一个x值向量,我想在图中添加垂直线,比如行向量: vec = [1 2 3 4 5]
我知道你可以像这样添加单个垂直线:
plot([1 1],[0 1])
(在y = 0到y = 1的情况下,在x = 1处给出垂直线)。
但是,当我尝试类似的东西
vec = [1 2 3 4 5]; lowLine = [0 0 0 0 0]; highLine = [1 1 1 1 1]; plot([vec vec],[lowLine highLine])
它没有给出所需的结果,而是给出了z形。 我哪里错了?
I have a vector of x-values at which I would like to add vertical lines to a graph, say a row vector: vec = [1 2 3 4 5]
I know that you can add single vertical lines like this:
plot([1 1],[0 1])
(gives a vertical line at x=1 from y=0 to y=1).
But when I try something like
vec = [1 2 3 4 5]; lowLine = [0 0 0 0 0]; highLine = [1 1 1 1 1]; plot([vec vec],[lowLine highLine])
It does not