Triangle function (derived from Sawtooth)
s.r.chinn
function tri(x, [v])
variable x, v
if (ParamIsDefault(v))
v = 0.5
endif
if (v>=1)
return sawtooth(x)
elseif (v<=0)
return 1 - sawtooth(x)
else
return sawtooth(x) * ((v - sawtooth(x))>=0) / v + sawtooth(-x) * ((1-v) - (sawtooth(-x)) >=0) / (1-v)
endif
end
variable x, v
if (ParamIsDefault(v))
v = 0.5
endif
if (v>=1)
return sawtooth(x)
elseif (v<=0)
return 1 - sawtooth(x)
else
return sawtooth(x) * ((v - sawtooth(x))>=0) / v + sawtooth(-x) * ((1-v) - (sawtooth(-x)) >=0) / (1-v)
endif
end
Attached is a graph with v=0.8
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
TriangleWave = tri(2*pi*x/period)
January 14, 2011 at 07:02 am - Permalink
variable t
variable temp = floor((4*t+1)/2)
return (4*t - 2*temp) * (-1)^temp
End
John Bechhoefer
Department of Physics
Simon Fraser University
Burnaby, BC, Canada
May 25, 2012 at 09:28 am - Permalink
... just add amplitude and period to taste :)
A.G.
May 25, 2012 at 10:53 am - Permalink