I am trying to produce a swept square or triangle wave. The chirp function produces a swept cosine wave; is there a way to do this with the square or sawtooth waves? My approach right now, at least for something like a square wave, is
V = A*chirp(t,f0,t1,f1, 'linear', -90); %#change the cosine wave to a sine wave
V(V<0) = -A;
V(V>0) = A;
I can do the same type of thing with a triangle wave, but it’s a little more annoying.
Generally speaking, is there a more straightforward way?
The swept-frequency is the same as evaluating a function
where
f(t), the time-varying frequency, is linear with time.Just write the equation for a line in two-points form:
and integrate:
The simplest form of this is when
t0 = f0 = phase0 = 0, then you get: