如何使用ZedGraph绘制方波?
如何使用ZedGraph绘制方波?
我正在考虑这样的事情:
alt text http:// /www.zsee.bytom.pl/sciaga/prad/grafika/okr%20prosto.jpg
我的公式是:
y = amplitude, if sin(x) >=0
y = -amplitude, if sin(x) < 0
理论上它应该给出方波,但给我:
How to draw square wave using ZedGraph?
I'm thinking about something like this:
alt text http://www.zsee.bytom.pl/sciaga/prad/grafika/okr%20prosto.jpg
My formula is:
y = amplitude, if sin(x) >=0
y = -amplitude, if sin(x) < 0
In theory it should give a square wave, but gives me:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该更改曲线的步进类型。使用:
当然
line
是你的LineItem
对象You should change the step type of your curve. Use:
of course
line
is yourLineItem
object看起来它沿着 X 轴以离散值步进(这实际上几乎是不可避免的),并从采样正 sin(x) 的最后一个点通过 sin 绘制一条陡峭的(但仍然明显不垂直)线(x)=0 到下一个采样负 sin(x) 的点。
明显的解决方法是告诉它以较小的间隔对函数进行采样 - 具体来说,足够小,以便从 +1 到 -1 (反之亦然)的过渡发生在小于像素宽度的情况下,最终显示它。
It looks like it's stepping at discrete values along the X axis (which is really almost unavoidable), and drawing a steep (but still visibly non-vertical) line from the last point at which it sampled a positive sin(x), through sin(x)=0 to the next point at which it sample a negative sin(x).
The obvious cure is to tell it to sample the function at smaller intervals -- specifically, small enough so the transition from +1 to -1 (or vice versa) happens in less than the width of a pixel as you'll end up displaying it.