2

这实际上是非常基本的,我以前(很久以前)做过,但现在找不到;我有一个数据点向量,我想用线图绘制;但是我希望线条是水平的并在每个点之间跳跃,这样它基本上看起来像一个直方图。我以为我可以使用具有特定 linespec 的plot(),但我找不到适合的。想法?

4

2 回答 2

2

我相信您正在寻找的功能是stairs

x = linspace(-2*pi,2*pi,40);
stairs(x,sin(x))
于 2013-02-02T19:16:07.957 回答
0

xy是要使用 绘制的两个相同大小的向量plot(x,y)。怎么样

yy = reshape( [y(:) y(:)]', 1, [] );
yy(end) = []; % discard last element
xx = reshape( [x(:) x(:)]', 1, [] );
xx(1) = []; % discard first element
plot( xx, yy );
title('does this do the trick for you?'); 
于 2013-02-02T19:05:37.230 回答