# cwtfreqbounds

CWT maximum and minimum frequency or period

## Syntax

## Description

`[`

returns the minimum and maximum wavelet bandpass frequencies in cycles/sample for a
signal of length `minfreq`

,`maxfreq`

] = cwtfreqbounds(`N`

)`N`

. The minimum and maximum frequencies are
determined for the default Morse (3,60) wavelet. The minimum frequency is determined
so that two time standard deviations of the default wavelet span the
`N`

-point signal at the coarsest scale. The maximum frequency
is such that the highest frequency wavelet bandpass filter drops to ½ of its peak
magnitude at the Nyquist frequency.

`[`

returns the bandpass periods for the sampling period `maxperiod`

,`minperiod`

] = cwtfreqbounds(`N`

,`Ts`

)`Ts`

.
`maxperiod`

and `minperiod`

are scalar
durations with the same format as `Ts`

. If the number of standard
deviations is set so that `log2(maxperiod/minperiod) < 1/NV`

where `NV`

is the number of voices per octave,
`maxperiod`

is adjusted to
`minperiod*2^(1/NV)`

.

`[___] = cwtfreqbounds(___,`

returns the minimum and maximum wavelet bandpass frequencies or periods with
additional options specified by one or more `Name,Value`

)`Name,Value`

pair
arguments.

## Examples

### Wavelet Bandpass Frequencies Using Default Values

Obtain the minimum and maximum wavelet bandpass frequencies for a signal with 1000 samples using the default values.

[minfreq,maxfreq] = cwtfreqbounds(1000)

minfreq = 0.0033

maxfreq = 0.4341

### Construct CWT Filter Bank With Peak Magnitude at Nyquist

Obtain the minimum and maximum wavelet bandpass frequencies for the default Morse wavelet for a signal of length 10,000 and a sampling frequency of 1kHz. Set the cutoff to 100% so that the highest frequency wavelet bandpass filter peaks at the Nyquist.

```
sigLength = 10000;
Fs = 1e3;
[minfreq,maxfreq] = cwtfreqbounds(sigLength,Fs,'cutoff',100);
```

Construct the filter bank using the values returned by `cwtfreqbounds`

. Plot the frequency response. Note that the highest frequency wavelet bandpass filter peaks at the Nyquist frequency of 500 Hz.

fb = cwtfilterbank('SignalLength',sigLength,'SamplingFrequency',Fs,'FrequencyLimits',[minfreq maxfreq]); freqz(fb)

Create a second frequency bank identical to the first, but instead use the default frequency limits. Plot the frequency response. In the case of the Morse wavelet, the CWT filter bank uses a default cutoff of 50% at the Nyquist.

fb2 = cwtfilterbank('SignalLength',sigLength,'SamplingFrequency',Fs); figure freqz(fb2)

## Input Arguments

`N`

— Signal length

positive integer

Signal length, specified as a positive integer greater than or equal to 4.

`Fs`

— Sampling frequency

positive scalar

Sampling frequency in hertz, specified as a positive scalar.

**Data Types: **`double`

`Ts`

— Sampling period

scalar duration

Sampling period, specified as a positive scalar `duration`

.

**Data Types: **`duration`

### Name-Value Arguments

Specify optional
comma-separated pairs of `Name,Value`

arguments. `Name`

is
the argument name and `Value`

is the corresponding value.
`Name`

must appear inside quotes. You can specify several name and value
pair arguments in any order as
`Name1,Value1,...,NameN,ValueN`

.

**Example:**

`'Wavelet',"amor",'CUTOFF',75`

`Wavelet`

— Analysis wavelet

`'Morse'`

(default) | `'amor'`

| `'bump'`

Analysis wavelet used to determine the minimum and maximum frequencies
or periods, specified as `'Morse'`

,
`'amor'`

, or `'bump'`

. These
strings specify the analytic Morse, Morlet, and bump wavelet,
respectively. The default wavelet is the analytic Morse (3,60)
wavelet.

For Morse wavelets, you can also parametrize the wavelet using the
`TimeBandwidth`

or
`WaveletParameters`

name-value pairs.

**Example: **`'Wavelet','bump'`

`CUTOFF`

— Percentage of the peak magnitude

50 for the Morse wavelet | 10 for the analytic Morlet and bump wavelets

Percentage of the peak magnitude at the Nyquist, specified as a scalar
between 0 and 100. Setting `CUTOFF`

to 0 indicates
that the wavelet frequency response decays to 0 at the Nyquist. Setting
`CUTOFF`

to 100 indicates that the value of the
wavelet bandpass filters peaks at the Nyquist.

**Data Types: **`double`

`StandardDeviations`

— Number of time standard deviations

2 (default)

Number of time standard deviations used to determine the minimum
frequency (longest scale), specified as a positive integer greater than
or equal to 2. For the Morse, analytic Morlet, and bump wavelets, four
standard deviations generally ensures that the wavelet decays to zero at
the ends of the signal support. Incrementing
'`StandardDeviations`

' by multiples of 4, for
example 4*M, ensures that M whole wavelets fit within the signal length.
If unspecified, '`StandardDeviations`

' defaults to 2.
If the number of standard deviations is set so that
log2(`minfreq`

/`maxfreq`

) >
-1/NV where NV is the number of voices per octave,
`minfreq`

is adjusted to
`maxfreq`

*2^(-1/NV).

**Data Types: **`double`

`TimeBandwidth`

— Time-bandwidth for Morse wavelets

positive scalar

This property is read-only.

Time-bandwidth for Morse wavelets, specified as a positive scalar.
This property is only valid when the `Wavelet`

property
is `'morse'`

. This property specifies the
time-bandwidth parameter of the Morse wavelet with the symmetry
parameter (gamma) fixed at 3. `TimeBandwidth`

is a
positive number strictly greater than 3 and less than or equal to 120.
The larger the time-bandwidth parameter, the more spread out the wavelet
is in time and narrower the wavelet is in frequency. The standard
deviation of the Morse wavelet in time is approximately
`sqrt(TimeBandwidth/2)`

. The standard deviation in
frequency is approximately
`1/2*sqrt(2/TimeBandwidth)`

.

The `TimeBandwidth`

and
`WaveletParameters`

properties cannot both be
specified.

**Example: **`'TimeBandwidth',4`

**Data Types: **`double`

`WaveletParameters`

— Morse wavelet parameters

`(3,60)`

(default) | two-element vector of scalars

This property is read-only.

Morse wavelet parameters, specified as a two-element vector. The first
element is the symmetry parameter (gamma), which must be greater than or
equal to 1. The second element is the time-bandwidth parameter, which
must be strictly greater than gamma. The ratio of the time-bandwidth
parameter to gamma cannot exceed 40. When gamma is equal to 3, the Morse
wavelet is perfectly symmetric in the frequency domain. The skewness is
equal to 0. Values of gamma greater than 3 result in positive skewness,
while values of gamma less than 3 result in negative skewness.
`WaveletParameters`

is only valid if the
`Wavelet`

property is set to
`'Morse'`

.

The `WaveletParameters`

and
`TimeBandwidth`

properties cannot both be
specified.

**Example: **`'WaveletParameters',[4,20]`

`VoicesPerOctave`

— Number of voices per octave

10 (default) | even integer between 4 and 48

Number of voices per octave to use in determining the necessary separation between the minimum and maximum scales, specified as an even integer between 4 and 48. The minimum and maximum scales are equivalent to the minimum and maximum frequencies or maximum and minimum periods respectively.

**Example: **`'VoicesPerOctave',20`

**Data Types: **`double`

## Output Arguments

`minfreq`

— Minimum wavelet bandpass frequency

scalar

Minimum wavelet bandpass frequency, returned as a scalar.
`minfreq`

is in cycles/sample if
`SamplingFrequency`

is not specified. Otherwise,
`minfreq`

is in hertz.

`maxfreq`

— Maximum wavelet bandpass frequency

scalar

Maximum wavelet bandpass frequency, returned as a scalar.
`maxfreq`

is in cycles/sample if
`SamplingFrequency`

is not specified. Otherwise,
`maxfreq`

is in hertz.

`maxperiod`

— Maximum wavelet bandpass period

scalar duration

Maximum wavelet bandpass period, returned as a scalar duration with the
same format as `Ts`

.

If the number of standard deviations is set so that
`log2(maxperiod/minperiod) < 1/NV`

where
`NV`

is the number of voices per octave,
`maxperiod`

is adjusted to
`minperiod*2^(1/NV)`

.

`minperiod`

— Minimum wavelet bandpass period

scalar duration

## Extended Capabilities

### C/C++ Code Generation

Generate C and C++ code using MATLAB® Coder™.

The `cwtfreqbounds`

function supports C/C++ code generation.
You must have MATLAB^{®}
Coder™ to generate C/C++ code.

Usage notes and limitations:

The sampling period (

`Ts`

) input argument is not supported.

## See Also

**Introduced in R2018a**

## Open Example

You have a modified version of this example. Do you want to open this example with your edits?

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

# Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)