Accelerating the pace of engineering and science

# chirp

Swept-frequency cosine

## Syntax

y = chirp(t,f0,t1,f1)
y = chirp(t,f0,t1,f1,'method')
y = chirp(t,f0,t1,f1,'method',phi)

## Description

y = chirp(t,f0,t1,f1) generates samples of a linear swept-frequency cosine signal at the time instances defined in array t, where f0 is the instantaneous frequency at time 0, and f1 is the instantaneous frequency at time t1. f0 and f1 are both in hertz. If unspecified, f0 is e-6 for logarithmic chirp and 0 for all other methods, t1 is 1, and f1 is 100.

y = chirp(t,f0,t1,f1,'method') specifies alternative sweep method options, where method can be:

• linear, which specifies an instantaneous frequency sweep fi(t)given by

${f}_{i}\left(t\right)={f}_{0}+\beta t$

where

$\beta =\left({f}_{1}-{f}_{0}\right)/{t}_{1}$

and the default value for f0 is 0. β ensures that the desired frequency breakpoint f1 at time t1 is maintained.

• quadratic, which specifies an instantaneous frequency sweep fi(t) given by

${f}_{i}\left(t\right)={f}_{0}+\beta {t}^{2}$

where

$\beta =\left({f}_{1}-{f}_{0}\right)/{t}_{1}$

and the default value for f0 is 0. If f0 > f1 (downsweep), the default shape is convex. If ff1 (upsweep), the default shape is concave.

• logarithmic specifies an instantaneous frequency sweep fi(t) given by

${f}_{i}\left(t\right)={f}_{0}×{\beta }^{t}$

where

$\beta ={\left(\frac{{f}_{1}}{{f}_{0}}\right)}^{\frac{1}{{t}_{1}}}$

and the default value for f0 is 1e-6. Both an upsweep (ff0) and a downsweep (f0 > f1) of frequency is possible.

Each of the above methods can be entered as 'li', 'q', and 'lo', respectively.

y = chirp(t,f0,t1,f1,'method',phi) allows an initial phase phi to be specified in degrees. If unspecified, phi is 0. Default values are substituted for empty or omitted trailing input arguments.

y = chirp(t,f0,t1,f1,'quadratic',phi,'shape') specifies the shape of the quadratic swept-frequency signal's spectrogram. shape is either concave or convex, which describes the shape of the parabola in the positive frequency axis. If shape is omitted, the default is convex for downsweep (f0 > f1) and is concave for upsweep (ff1).

## Examples

### Example 1

Compute the spectrogram of a chirp with linear instantaneous frequency deviation:

```t = 0:0.001:2;            % 2 secs @ 1kHz sample rate
y = chirp(t,0,1,150);     % Start @ DC,
%   cross 150Hz at t=1 sec
spectrogram(y,256,250,256,1E3,'yaxis')
```

### Example 2

Compute the spectrogram of a chirp with quadratic instantaneous frequency deviation:

```% ±2 secs @ 1kHz sample rate
t = -2:0.001:2;

% Start @ 100Hz, cross 200Hz at t=1 sec

spectrogram(y,128,120,128,1E3,'yaxis')
```

### Example 3

Compute the spectrogram of a convex quadratic chirp:

```t = -1:0.001:1;         % +/-1 second @ 1kHz sample rate
fo = 100; f1 = 400;     % Start at 100Hz, go up to 400Hz
y = chirp(t,fo,1,f1,'q',[],'convex');
spectrogram(y,256,200,256,1000,'yaxis')
```

### Example 4

Compute the spectrogram of a concave quadratic chirp:

```t = 0:0.001:1;       % 1 second @ 1kHz sample rate
fo = 100; f1 = 25;   % Start at 100Hz, go down to 25Hz
y = chirp(t,fo,1,f1,'q',[],'concave');
spectrogram(y,hanning(256),128,256,1000,'yaxis')
```

### Example 5

Compute the spectrogram of a logarithmic chirp:

```t = 0:0.001:10;      % 10 seconds @ 1kHz sample rate
fo = 10; f1 = 400;   % Start at 10Hz, go up to 400Hz
y = chirp(t,fo,10,f1,'logarithmic');
spectrogram(y,256,200,256,1000,'yaxis')
```