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:
+2
source to share
2 answers
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 to share