GLE Example: square.gle

[PDF file]

 


! Example of combining datasets

size 10 7

set font texcmr
begin graph
   scale auto
   title "Synthesis of a square wave"
   yaxis min -1.1 max 1.1
   xaxis min 0    max 5*pi dticks pi format "pi"
   xsubticks off
   let d1  = sin(x)   step 0.02        ! The fundamental sine wave
   let d2  = sin(3*x) step 0.02        ! Various harmonics over
   let d3  = sin(5*x) step 0.02        ! the fundamental
   let d4  = sin(7*x) step 0.02
   let d5  = sin(9*x) step 0.02
   let d20 = sgn(d1)                   ! The square wave
   let d10 = d1+(1/3)*d2               ! We take linear combinations
   let d11 = d10+(1/5)*d3              ! of the various frequencies
   let d12 = d11+(1/7)*d4
   let d13 = d12+(1/9)*d5
   d1  line color gray10               ! These could also be plotted
   d10 line color gray20               ! in different colors or line
   d11 line color gray40               ! styles to make the difference
   d12 line color gray60               ! clearer. A key may also help
   d13 line color gray80
   d20 line color red lstyle 2
end graph

 

[Return to examples page]