# Graph of aliasing frequencies
# Triangle wave
# Set terminal
set terminal svg enhanced size 300 200 fs 10
set samples 1001 # high quality
set border 31 linewidth .3 # thin border
set output "aliasing-folding.svg"
# Ranges
set xrange [-.2:2.2] # 2 cycles, with room for labels
set xtics ( \
"0" 0, \
"fs/4" .25, "fs/2" .5, "3fs/4" .75, "fs" 1, \
"5fs/4" 1.25, "3fs/2" 1.5, "7fs/4" 1.75, "2fs" 2 \
) # Key feature (fold) is at .5; add .25 for reference
set yrange [-.1:1.1] # Slight headroom from max of 1
set ytics ( \
"0" 0, "fs/4" .5, "fs/2" 1 \
) # Corresponding y values
# Zero axes and grid as guidelines, no key (self-explanatory)
set zeroaxis
set grid
unset key
###########################
# Define and plot function
###########################
tri(x) = acos(cos(2*pi*x))/pi # normalized triangle wave
plot tri(x)