# featureMatrix

Scattering feature matrix

## Syntax

``smat = featureMatrix(sf,x)``
``smat = featureMatrix(sf,s)``
``smat = featureMatrix(___,Name,Value)``

## Description

````smat = featureMatrix(sf,x)` returns the scattering features for the scattering decomposition framework `sf` and the input signal `x`. `x` is a real-valued vector or matrix. If `x` is a vector, `smat` is an M-by-N matrix, where M is the number of resolutions across all orders of the scattering transform, and N is the resolution of the scattering coefficients. If `x` is a matrix, `smat` is an M-by-N-by-P array, where P is the number of columns in `x`.The precision of `smat` depends on the precision specified in the framework `sf`.```
````smat = featureMatrix(sf,s)` returns the scattering feature matrix for the cell array of scattering coefficients `s`. `s` is the output of `scatteringTransform` applied to an input signal for the scattering decomposition framework `sf`.```

example

````smat = featureMatrix(___,Name,Value)` returns the scattering feature matrix with additional options specified by one or more `Name,Value` pair arguments.```

## Examples

collapse all

This example shows how to obtain the scattering feature matrix for a scattering decomposition framework and how to compare the matrix with scattering coefficients.

Load an ECG signal sampled at 180 Hz. Create a scattering decomposition framework that can be used with the signal.

```load wecg Fs = 180; sf = waveletScattering('SignalLength',numel(wecg),... 'SamplingFrequency',Fs);```

Calculate the scattering feature matrix using the log transformation. Display the dimensions of the matrix.

```smat = featureMatrix(sf,wecg,'Transform','Log'); size(smat)```
```ans = 1×2 154 8 ```

Now calculate the scattering transform of the signal. Obtain the scattering coefficients. The output is a cell array with three elements. Each element is a table. Confirm the total number of rows in the tables is equal to the number of rows in the matrix.

```S = scatteringTransform(sf,wecg); t1rows = size(S{1},1); t2rows = size(S{2},1); t3rows = size(S{3},1); disp(['Total Number of Rows: ',num2str(t1rows+t2rows+t3rows)])```
```Total Number of Rows: 154 ```

Display the base-2 log resolution of the zeroth-order scattering coefficients.

`disp(['Resolution: ',num2str(S{1}.resolution(1))])`
```Resolution: -8 ```

Obtain the natural logarithm of the zeroth-order scattering coefficients. Compare the scattering coefficients with the first row in the feature matrix. The number of coefficients in each equals the absolute value of the base-2 log resolution.

```logS = log(sf,S); logScat = logS{1}.signals{1}; [smat(1,:)' logScat]```
```ans = 8×2 -1.2914 -1.2914 -2.4682 -2.4682 -1.6368 -1.6368 -1.2716 -1.2716 -1.6818 -1.6818 -4.3701 -4.3701 -1.3199 -1.3199 -1.0542 -1.0542 ```

## Input Arguments

collapse all

Scattering decomposition framework, specified as a `waveletScattering` object.

Input data, specified as a real-valued vector or matrix. If `x` is a vector, the number of samples in `x` must equal the `SignalLength` value of `sf`. If `x` is a matrix, the number of rows in `x` must equal the `SignalLength` value of `sf`.

Data Types: `double`

Scattering coefficients, specified as a cell array. `s` is obtained from the scattering transform of the scattering decomposition framework `sf`. For more information, see `scatteringTransform`.

### 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: ```smat = featureMatrix(sf,x,'Transform','log','Normalization','parent')```

Type of normalization to apply to the scattering coefficients, specified as `'none'` or `'parent'`. If specified as `'parent'`, scattering coefficients of order greater than 0 are normalized by their parents along the scattering path.

Type of transformation to apply to the scattering coefficients, specified as `'none'` or `'log'`.

## Output Arguments

collapse all

Scattering features for the scattering decomposition framework, `sf`, returned as a real-valued matrix or array. If `x` is a vector, `smat` is an M-by-N matrix, where M is the number of resolutions across all orders of the scattering transform and N is the resolution of the scattering coefficients. If `x` is a matrix, `smat` is an M-by-N-by-P array, where P is the number of columns in `x`.

The precision of `smat` depends on the precision specified in the framework `sf`. 