Input signal, specified as a row or column vector.

**Example: **`cos(pi/4*(0:159))+randn(1,160)`

specifies
a sinusoid embedded in white Gaussian noise.

**Data Types: **`single`

| `double`

**Complex Number Support: **Yes

Window, specified as an integer or as a row or column vector.
Use `window`

to divide the signal into sections:

If `window`

is an integer, then `spectrogram`

divides `x`

into
sections of length `window`

and windows each section
with a Hamming window of that length.

If `window`

is a vector, then `spectrogram`

divides `x`

into
sections of the same length as the vector and windows each section
using `window`

.

If the length of `x`

cannot be divided
exactly into an integer number of sections with `noverlap`

overlapping
samples, then `x`

is truncated accordingly.

If you specify `window`

as empty, then `spectrogram`

uses
a Hamming window such that `x`

is divided into
eight sections with `noverlap`

overlapping samples.

For a list of available windows, see Windows.

**Example: **`hann(N+1)`

and `(1-cos(2*pi*(0:N)'/N))/2`

both
specify a Hann window of length `N`

+ 1.

**Data Types: **`single`

| `double`

Number of overlapped samples, specified as a positive integer.

If `window`

is scalar, then `noverlap`

must
be smaller than `window`

.

If `window`

is a vector, then `noverlap`

must
be smaller than the length of `window`

.

If you specify `noverlap`

as empty,
then `spectrogram`

uses a number that produces 50%
overlap between sections. If the section length is unspecified, the
function sets `noverlap`

to ⌊*N*_{x}/4.5⌋,
where *N*_{x} is the length of
the input signal.

**Data Types: **`double`

| `single`

Number of DFT points, specified as a positive integer scalar.
If you specify `nfft`

as empty, then `spectrogram`

sets
the parameter to max(256,2^{p}),
where *p* = ⌈log_{2} *N*_{x}⌉ for
an input signal of length *N*_{x}.

**Data Types: **`single`

| `double`

Normalized frequencies, specified as a vector. `w`

must
have at least two elements. Normalized frequencies are in rad/sample.

**Example: **`pi./[2 4]`

**Data Types: **`double`

| `single`

Cyclical frequencies, specified as a vector. `f`

must
have at least two elements. The units of `f`

are
specified by the sample rate, `fs`

.

**Data Types: **`double`

| `single`

Sample rate, specified as a positive scalar. The sample rate
is the number of samples per unit time. If the unit of time is seconds,
the sampling frequency is in Hz.

**Data Types: **`double`

| `single`

Frequency range for the PSD estimate, specified as `'onesided'`

, `'twosided'`

,
or `'centered'`

. For real-valued signals, the default
is `'onesided'`

. For complex-valued signals, the
default is `'twosided'`

.

`'onesided'`

— returns the
one-sided spectrogram of a real input signal. If `nfft`

is
even, then `pxx`

has length `nfft`

/2 + 1 and is computed over the interval [0, *π*] rad/sample.
If `nfft`

is odd, then `pxx`

has
length (`nfft`

+ 1)/2
and the interval is [0, *π*) rad/sample.
If you specify `fs`

, then the intervals are respectively
[0, `fs`

/2] cycles/unit time and
[0, `fs`

/2) cycles/unit time.

`'twosided'`

— returns the
two-sided spectrogram of a real or complex signal. `pxx`

has
length `nfft`

and is computed over the interval [0, 2*π*) rad/sample.
If you specify `fs`

, then the interval is [0, `fs`

) cycles/unit time.

`'centered'`

— returns the
centered two-sided spectrogram for a real or complex signal. `pxx`

has
length `nfft`

. If `nfft`

is
even, then `pxx`

is computed over the interval (–*π*, *π*] rad/sample.
If `nfft`

is odd, then `pxx`

is
computed over (–*π*, *π*) rad/sample.
If you specify `fs`

, then the intervals are respectively
(–`fs`

/2, `fs`

/2] cycles/unit time and (–`fs`

/2, `fs`

/2) cycles/unit
time.

**Data Types: **`char`

Power spectrum scaling, specified as `'psd'`

or `'power'`

.

Omitting `spectrumtype`

, or specifying `'psd'`

,
returns the power spectral density.

Specifying `'power'`

scales each
estimate of the PSD by the equivalent noise bandwidth of the window.
The result is an estimate of the power at each frequency.

**Data Types: **`char`

Frequency display axis, specified as `'xaxis'`

or `'yaxis'`

.

This argument is ignored if you call `spectrogram`

with
output arguments.

**Data Types: **`char`