Extension to Mathematica/WL
SquareWave[ ] and TriangleWave[ ]
Extension to Mathematica/WL
SquareWave[ ] and TriangleWave[ ]
SquareWave[ ] and TriangleWave[ ]
Explanation
Explanation
The Mathematica built in “Wave” functions only support 50% duty cycle for
SquareWave[ ] as well as for TriangleWave[ ].
SquareWave[ ] as well as for TriangleWave[ ].
Here we present compatible versions with adjustable duty cycle.
The new function PulseWave[ ] generates a pulse sequence with adjustable duty cycle,
which defaults to and thus includes the SquareWave[ ] functionality.
The new function PulseWave[ ] generates a pulse sequence with adjustable duty cycle,
which defaults to and thus includes the SquareWave[ ] functionality.
GeneralTriangleWave[ ] on the other hand includes the TriangleWave[ ] functionality with the possibility to generate non symmetric triangle pulse sequences. Again the TriangleWave[ ] functionality is included.
Moreover also the SawtoothWave[ ] functionality is included, although the latter is not exactly compatible with respect to the default arguments.
Moreover also the SawtoothWave[ ] functionality is included, although the latter is not exactly compatible with respect to the default arguments.
Implementation
Implementation
Examples
Examples
In[]:=
PlotPulseWave,x,SquareWave[x],{x,-2,2},PlotStyle{Red,{Black,Dashed}}//Framed//(pLabeled[p,"PulseWave vs. SquareWave"])
1
2
Out[]=
PulseWave vs. SquareWave |
In[]:=
PlotPulseWave,x,{x,-2,2}//Framed//(pLabeled[p,"25% duty cycle"])
1
4
Out[]=
25% duty cycle |
In[]:=
PlotGeneralTriangleWave,x,TriangleWave[x],{x,-2,2},PlotStyle{Red,{Black,Dashed}}//Framed//(pLabeled[p,"GeneralTriangleWave vs. TriangleWave"])
1
2
Out[]=
GeneralTriangleWave vs. TriangleWave |
In[]:=
PlotGeneralTriangleWave{10,12},,x,{x,-2,2}//Framed//(pLabeled[p,"25% asymmetric"])
1
4
Out[]=
25% asymmetric |
In[]:=
Plot[GeneralTriangleWave[0,x],{x,-2,2}]//Framed//(pLabeled[p,"Sawtooth mode by 0% duty cycle"])
Out[]=
Sawtooth mode by 0% duty cycle |