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

startfreq=200;
fs=44100;
endfreq=20;
dursec= 10;%duration of signal in seconds
t=(0:dursec*fs)/fs; %Time vector
alpha=log(startfreq/endfreq)/dursec;
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
specgram(sig,150,400);


1st plot

2nd plot

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

• I cannot reproduce your result, this is what i got: i.stack.imgur.com/DR2cS.png – lennon310 Feb 20 '14 at 14:54
• @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? – Rick T Feb 20 '14 at 15:44
• 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 – lennon310 Feb 20 '14 at 15:49
• @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. – Rick T Feb 20 '14 at 16:09

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).

$190=20+180(1-\exp(-2\alpha))$

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))$