# scatteringTransform

## Description

## Examples

### Scattering Transform of ECG Signal

This example shows how to return the wavelet 1-D scattering transform of a real-valued signal.

Load an ECG signal sampled at 180 Hz.

```
load wecg
Fs = 180;
```

Create a wavelet time scattering network to apply to the signal. Compute the scattering transform of the signal.

sf = waveletScattering('SignalLength',numel(wecg),... 'SamplingFrequency',Fs)

sf = waveletScattering with properties: SignalLength: 2048 InvarianceScale: 5.6889 QualityFactors: [8 1] Boundary: 'periodic' SamplingFrequency: 180 Precision: 'double' OversamplingFactor: 0 OptimizePath: 0

[S,U] = scatteringTransform(sf,wecg);

Plot the signal and the zeroth-order scattering coefficients. Note that the invariance scale is one half the duration of the signal.

t = [0:length(wecg)-1]/Fs; subplot(2,1,1) plot(t,wecg) grid on axis tight xlabel('Seconds') title('ECG Signal') subplot(2,1,2) plot(S{1}.signals{1},'x-') grid on axis tight title('Zeroth-Order Scattering Coefficients')

Visualize the scattergram for the first-order scalogram coefficients.

```
figure
scattergram(sf,U,'FilterBank',1)
```

## Input Arguments

`sf`

— Wavelet time scattering network

`waveletScattering`

object

Wavelet time scattering network, specified as a `waveletScattering`

object.

`x`

— Input data

vector | matrix | 3-D array

Input data, specified as a real-valued vector, matrix, or 3-D array. If
`x`

is a vector, the number of samples in `x`

must equal the `SignalLength`

value of `sf`

. If
`x`

is a matrix or 3-D array, the number of rows in
`x`

must equal the `SignalLength`

value of
`sf`

. If `x`

is 2-D, the first dimension is
assumed to be time and the columns of `x`

are assumed to be separate
channels. If `x`

is 3-D, the dimensions of `x`

are
Time-by-Channel-by-Batch.

**Data Types: **`single`

| `double`

## Output Arguments

`s`

— Scattering coefficients

cell array

Scattering coefficients, returned as a *NO*-by-1 cell array, where
*NO* is the number of orders in `sf`

.

Each element of `s`

is a MATLAB^{®} table with the following variables:

`signals`

— Scattering coefficients

cell array

Scattering coefficients, returned as a cell array. If `x`

is a vector, each element of `signals`

is a
*Ns*-by-1 vector, where *Ns* is the number of
scattering coefficients. If `x`

is 2-D, each element of
`signals`

is a *Ns*-by-*Nc*
matrix, where *Nc* is the number of channels in
`x`

. If `x`

is 3-D, each element of
`signals`

is a
*Ns*-by-*Nc*-by-*Nb* array,
where *Nb* is the number of batches in
`x`

.

**Data Types: **`single`

| `double`

`path`

— Scattering path

row vector

Scattering path used to obtain the scattering coefficients, returned as a row
vector. Each column of `path`

corresponds to one element of the
path. The scalar 0 denotes the original signal. Positive integers in the
*L*^{th} column denote the
corresponding wavelet filter in the
(*L*-1)^{th} filter bank. Wavelet
bandpass filters are ordered by decreasing center frequency.

**Data Types: **`double`

`bandwidth`

— Bandwidth of scattering coefficients

scalar

Bandwidth of the scattering coefficients, returned as a scalar. If you specify a sampling frequency in the scattering network, the bandwidth is in hertz. Otherwise, the bandwidth is in cycles/sample.

**Data Types: **`double`

`resolution`

— Base-2 log resolution

scalar

Base-2 log resolution of the scattering coefficients, returned as a scalar.

**Data Types: **`double`

`u`

— Scalogram coefficients

cell array

Scalogram coefficients, returned as a *NO*-by-1 cell array, where
*NO* is the number of orders in `sf`

. The
*i*th element of `u`

are the scalogram
coefficients for the *i*th row of `s`

.

Each element of `u`

is a MATLAB table with the following variables:

`coefficients`

— Scalogram coefficients

cell array

Scalogram coefficients, returned as a cell array. If `x`

is
a vector, each element of `coefficients`

is a
*Nu*-by-1 vector, where *Nu* is the number of
scalogram coefficients. If `x`

is 2-D, each element of
`coefficients`

is a
*Nu*-by-*Nc* matrix, where
*Nc* is the number of channels in `x`

. If
`x`

is 3-D, each element of `coefficients`

is a *Nu*-by-*Nc*-by-*Nb*
array, where *Nb* is the number of batches in
`x`

.

Note that `u{1}`

contains the original data in the
coefficients variable.

**Data Types: **`single`

| `double`

`path`

— Scattering path

row vector

Scattering path used to obtain the scalogram coefficients, returned as a row
vector. Each column of `path`

corresponds to one element of the
path. The scalar 0 denotes the original signal. Positive integers in the
*L*^{th} column denote the
corresponding wavelet filter in the
(*L*-1)^{th} filter bank. Wavelet
bandpass filters are ordered by decreasing center frequency.

**Data Types: **`double`

`bandwidth`

— Bandwidth of scalogram coefficients

scalar

Bandwidth of the scalogram coefficients, returned as a scalar. If you specify a sampling frequency in the scattering network, the bandwidth is in hertz. Otherwise, the bandwidth is in cycles/sample.

**Data Types: **`double`

`resolution`

— Base-2 log resolution

scalar

Base-2 log resolution of the scalogram coefficients, returned as a scalar.

**Data Types: **`double`

## Tips

The

`scatteringTransform`

function calls`featureMatrix`

to generate the scattering and scalogram coefficients. If you only require the coefficients themselves, for improved performance the recommended approach is to use`featureMatrix`

. Use`scatteringTransform`

if you are also interested in the coefficients metadata.

## Extended Capabilities

### C/C++ Code Generation

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

### GPU Arrays

Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.

This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

## Version History

**Introduced in R2018b**

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