# freqz

CWT filter bank frequency responses

## Description

`[`

returns the frequency responses for the wavelet filters,
`psidft`

,`f`

] = freqz(`fb`

)`psidft`

, and the frequency vector, `f`

, for
the continuous wavelet transform (CWT) filter bank, `fb`

.
Frequencies are in cycles/sample or Hz. If you specify a sampling period, the
frequencies are in cycles/unit time where the time unit is the unit of the duration
sampling period.

The frequency responses, `psidft`

, are one-sided frequency
responses for the positive frequencies. For the analytic wavelets supported by
`cwtfilterbank`

, the frequency responses are real-valued and are
equivalent to the magnitude frequency response.

`[___] = freqz(___,`

specifies one or more additional name-value arguments. For example, `Name=Value`

)```
psidft
= freqz(fb,FrequencyRange="twosided")
```

returns the full two-sided
frequency responses.

## Examples

### Invert CWT Using Approximate Synthesis Filters

Load the Kobe earthquake data. Create a CWT filter bank with period boundary handling that you can apply to the data.

load kobe fb = cwtfilterbank(SignalLength=numel(kobe),Boundary="periodic");

Obtain the two-sided wavelet and scaling filter responses.

`[psidft,f] = freqz(fb,IncludeLowpass=true,FrequencyRange="twosided");`

Obtain the CWT of the data. Also obtain the scaling coefficients.

[cfs,~,~,scalcfs] = wt(fb,kobe);

Invert the transform using the filter bank and the scaling coefficients.

```
xrec = icwt(cfs,ScalingCoefficients=scalcfs,AnalysisFilterBank=psidft);
plot([kobe(:) xrec(:)])
axis tight
```

Obtain the maximum reconstruction error.

`norm(kobe(:)-xrec(:),'Inf')`

ans = 2.9104e-11

### Frequency Responses of Continuous Wavelet Transform Filter Bank

Create a CWT filter bank. Set the voices per octave to 14, the sampling frequency to 1000 Hz, and frequency limits to range from 200 Hz to 300 Hz.

```
fb = cwtfilterbank(VoicesPerOctave=14,...
SamplingFrequency=1000,FrequencyLimits=[200 300]);
```

Plot the frequency responses.

freqz(fb)

### Boundary Handling and Frequency Range

This example shows how boundary handling and signal length affect the range of frequency responses `freqz`

returns.

**Reflection / Even Length**

Create a CWT filter bank suitable for an even-length signal. Use the default `Boundary`

setting `reflection`

.

sLen = 256; fb = cwtfilterbank(SignalLength=sLen);

Obtain the one-sided frequency responses of the filter bank. Also obtain the frequency vector.

`[psidft,f] = freqz(fb,FrequencyRange="onesided");`

Confirm the range of frequencies includes the Nyquist.

f(end)

ans = 0.5000

Plot the frequency response of the filter with the highest center frequency.

plot(f,psidft(1,:)) xlabel("Frequency (samples/cycle)") ylabel("Magnitude") title("Reflection / Even / One-sided")

Obtain and plot the two-sided frequency responses. Confirm the frequency range does not include the Nyquist.

```
[psidft,f] = freqz(fb,FrequencyRange="twosided");
f(end)
```

ans = 0.9980

plot(f,psidft(1,:)) xlabel("Frequency (samples/cycle)") ylabel("Magnitude") title("Reflection / Even / Two-sided")

**Reflection / Odd Length**

Create a CWT filter bank suitable for an odd-length signal. Use the default `Boundary`

setting `reflection`

.

sLen = 255; fb = cwtfilterbank(SignalLength=sLen);

Obtain the one-sided frequency responses of the filter bank. Confirm the range of frequencies does not include the Nyquist.

```
[~,f] = freqz(fb,FrequencyRange="onesided");
f(end)
```

ans = 0.4990

**Periodic / Even Length**

Create a CWT filter bank with periodic boundary handling suitable for an even-length signal

```
sLen = 256;
fb = cwtfilterbank(SignalLength=sLen,Boundary="periodic");
```

Obtain the one-sided frequency responses of the filter bank. Confirm the range of frequencies does include the Nyquist.

```
[~,f] = freqz(fb,FrequencyRange="onesided");
f(end)
```

ans = 0.5000

**Periodic / Odd Length**

Create a CWT filter bank with periodic boundary handling suitable for an odd-length signal

```
sLen = 255;
fb = cwtfilterbank(SignalLength=sLen,Boundary="periodic");
```

Obtain the one-sided frequency responses of the filter bank. Confirm the range of frequencies does not include the Nyquist.

```
[~,f] = freqz(fb,FrequencyRange="onesided");
f(end)
```

ans = 0.4980

## Input Arguments

`fb`

— Continuous wavelet transform filter bank

`cwtfilterbank`

object

Continuous wavelet transform (CWT) filter bank, specified as a `cwtfilterbank`

object.

### Name-Value Arguments

Specify optional pairs of arguments as
`Name1=Value1,...,NameN=ValueN`

, where `Name`

is
the argument name and `Value`

is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.

**Example: **`psidft = freqz(fb,IncludeLowpass=true)`

appends the
lowpass, or scaling filter, frequency response as the final row of
`psidft`

.

`IncludeLowpass`

— Append lowpass filter frequency response

`false`

or
`0`

(default) | `true`

or `1`

Option to append lowpass, or scaling filter, frequency response as the
final row of `psidft`

, specified as one of these:

`1`

(`true`

) — Include the frequency response symmetrically`0`

(`false`

) — Do not include the frequency response

For the analytic wavelets supported by `cwtfilterbank`

, the scaling filter frequency response is
real-valued and is equivalent to the magnitude frequency
response.

**Data Types: **`logical`

`FrequencyRange`

— Frequency range for filter responses

`"onesided"`

(default) | `"twosided"`

Frequency range for the wavelet and scaling function frequency
responses, specified as one of `"onesided"`

, or
`"twosided"`

. The frequency ranges corresponding to
each option are

`"onesided"`

— returns the frequency responses from [0,½] when the length of the padded filters is even and [0,½) when the length of the padded filters is odd. Padding is added when the Boundary property of the filter bank is`"reflection"`

.If a sampling frequency

*Fs*is specified in the filter bank, the intervals become [0,*Fs*/2] and [0,*Fs*/2) respectively.`"twosided"`

— returns the full two-sided frequency responses over the range [0,1). If a sampling frequency*Fs*is specified in the filter bank, the interval becomes [0,*Fs*).

**Note**

To use the wavelet and scaling filters in the inverse CWT, set
Boundary in the filter bank to
`"periodic"`

, and use

and
`IncludeLowpass`

=true

in `FrequencyRange`

="twosided"`freqz`

.

## Output Arguments

`psidft`

— Frequency responses

real-valued 2-D matrix

Frequency responses of a CWT filter bank, returned as a real-valued
matrix. Each column of `psidft`

is the response at the
frequency in the corresponding element of `f`

.

By default, frequency responses, `psidft`

, are one-sided
frequency responses for the positive frequencies. For the analytic wavelets
supported by `cwtfilterbank`

, the frequency responses are real-valued and
are equivalent to the magnitude frequency response.

**Data Types: **`double`

`f`

— Frequencies

real-valued vector

Frequencies, in cycles/sample or hertz, returned as a real-valued vector.

If you specify a sampling period, the frequencies are in cycles/unit
time, where the time unit is the unit of the duration
`SamplingPeriod`

.

**Data Types: **`double`

## Extended Capabilities

### C/C++ Code Generation

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

Usage notes and limitations:

Plotting is not supported.

## Version History

**Introduced in R2018a**

## See Also

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