# cwtfreqbounds

CWT maximum and minimum frequency or period

## Syntax

``[minfreq,maxfreq] = cwtfreqbounds(N)``
``[minfreq,maxfreq] = cwtfreqbounds(N,Fs)``
``[maxperiod,minperiod] = cwtfreqbounds(N,Ts)``
``[___] = cwtfreqbounds(___,Name,Value)``

## Description

example

````[minfreq,maxfreq] = cwtfreqbounds(N)` returns the minimum and maximum wavelet bandpass frequencies in cycles/sample for a signal of length `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.```
````[minfreq,maxfreq] = cwtfreqbounds(N,Fs)` returns the bandpass frequencies in hertz for the sampling frequency `Fs`.```
````[maxperiod,minperiod] = cwtfreqbounds(N,Ts)` returns the bandpass periods for the sampling period `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)`.```

example

````[___] = cwtfreqbounds(___,Name,Value)` returns the minimum and maximum wavelet bandpass frequencies or periods with additional options specified by one or more `Name,Value` pair arguments.```

## Examples

collapse all

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 ```

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

collapse all

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

Sampling frequency in hertz, specified as a positive scalar.

Data Types: `double`

Sampling period, specified as a positive scalar `duration`.

Data Types: `duration`

### Name-Value Pair 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`

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'`

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`

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`

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`

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]`

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

collapse all

Minimum wavelet bandpass frequency, returned as a scalar. `minfreq` is in cycles/sample if `SamplingFrequency` is not specified. Otherwise, `minfreq` is in hertz.

Maximum wavelet bandpass frequency, returned as a scalar. `maxfreq` is in cycles/sample if `SamplingFrequency` is not specified. Otherwise, `maxfreq` is in hertz.

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

Minimum 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)`

## Extended Capabilities 