When I do a spectrogram in matlab / octave I can create a swept signal that looks like the RED plot line below. But how can I create a swept signal like the BLUE line in the 1st plot using the equation below.

thanks to Daniel and David for getting me this far with the code is below

dursec= 10;%duration of signal in seconds
t=(0:dursec*fs)/fs; %Time vector
sig = exp(-j*2*pi*startfreq/alpha*exp(-alpha*t));
sig=(sig/max(abs(sig))*.8); %normalize signal
wavwrite([sig'] ,fs,32,strcat('/tmp/del.wav')); %export file

1st plot Plot that I'm trying to reproduce

2nd plot Plot with 200hz-20hz works

How can I fix the the equation in the variable sig to get it to look like the BLUE line in the 1st plot?

3rd plot Plot with 20hz-200hz which doesn't do what I want

  • $\begingroup$ I cannot reproduce your result, this is what i got: i.stack.imgur.com/DR2cS.png $\endgroup$
    – lennon310
    Feb 20, 2014 at 14:54
  • $\begingroup$ @lennon310 strange I just copied the code directly above and ran it again in octave which the plots look like above and in matlab which look likes i.imgur.com/E4XyXV9.png Are you using the code above? I noticed some of the numbers on your plot aren't the same as mine. What code did you use? $\endgroup$
    – Rick T
    Feb 20, 2014 at 15:44
  • $\begingroup$ Rick, I just copied your code directly (only with fs=5e4; everything else is exactly the same). I think it may be due to the specgram function. My matlab doesn't include the signal processing toolbox, so I used the function here: redwood.berkeley.edu/bruno/npb163/data/specgram.m $\endgroup$
    – lennon310
    Feb 20, 2014 at 15:49
  • $\begingroup$ @lennon310 ok that may explain it, the function your using somehow switches the axis's around some how compared to octave/matlab/audacity you can tell this by the frequency numbers being incorrect if you go from 200hz to 20hz it should be a downward curve not an upward curve. I just checked the signal using audacity's spectrogram to verify and if I go from 200hz to 20hz or 20hz to 200hz the signal does it correctly. It looks like the function your using may have the axis's switched somehow. $\endgroup$
    – Rick T
    Feb 20, 2014 at 16:09

1 Answer 1


The general formula for the exponential rise in frequency is given by

$f=A+B(1-\exp(-\alpha t))$

We need to solve for the values of $A$, $B$ and $\alpha$. Let's assume you want an initial frequency of $20$ at time $t=0$, and an asymptotic frequency of $200$ Hz at time $t=\infty$.

Substituting $t=0$ and $f=20$ into the above equation we find $A=20$. If we substitute $t=\infty$ and $f=200$ we find that $B=180$. For $\alpha$ you really have a free choice - it controls how fast the frequency rises. If you have another control point say at time $t=2$ we want the frequency to be at $95%$ of the final frequency i.e. $f=.95 \times 200=190$ then we can substitute these into the above equation (Since we know what $A$, and $B$ are).


Solving gives $\alpha= -0.5\ln(10/180)=-1.445$. If you want a faster rise then you'll need to choose a larger value of $\alpha$.

To find the expression for phase we simply integrate with respect to time to give

$\phi =2\pi(At+Bt+\frac{B}{\alpha}\exp(-\alpha t))$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.