How do I draw a square wave using ZedGraph?

How do I draw a square wave using ZedGraph ?

I am thinking of something like this:

alt text http://www.zsee.bytom.pl/sciaga/prad/grafika/okr%20prosto.jpg

My formula:

y =  amplitude, if sin(x) >=0

y = -amplitude, if sin(x) < 0

      

In theory this should give a square wave, but it gives me:

alt text http://img27.imageshack.us/img27/9813/xxxmy.png

+2


source to share


2 answers


You must change the type of curve step. Using:

line.Line.StepType = StepType.ForwardStep;

      



of course line

- your objectLineItem

+4


source


It looks like it will step on discrete values โ€‹โ€‹along the X-axis (which is indeed almost inevitable) and pulls out a steep (but still visible non-vertical) line from the last point it tried a positive sin (x) through sin (x) = 0 to the next point at which it tries a negative sin (x).



The obvious cure is to tell him to try the function at smaller intervals - in particular, small enough so that the transition from +1 to -1 (or vice versa) happens to be less than the pixel width as you end up displaying his.

+2


source







All Articles