开发者

How to draw a square wave using ZedGraph?

开发者 https://www.devze.com 2022-12-09 06:07 出处:网络
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

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:

alt text http://img27.imageshack.us/img27/9813/xx开发者_C百科xmy.png


You should change the step type of your curve. Use:

line.Line.StepType = StepType.ForwardStep;

of course line is your LineItem object


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消