# MATLAB

## MATLAB Usage Guide

Select a card below to access MATLAB-specific usage information.&#x20;

<table data-view="cards"><thead><tr><th></th><th align="center"></th><th></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td></td><td align="center"><strong>Installation</strong></td><td></td><td><a href="/files/RjBXWwudtJom3W0YZ4Wr">/files/RjBXWwudtJom3W0YZ4Wr</a></td><td><a href="/pages/ACUF6I6ykXCpaJqs4csm#installation">/pages/ACUF6I6ykXCpaJqs4csm#installation</a></td></tr><tr><td></td><td align="center"><strong>Getting started</strong></td><td></td><td><a href="/files/bFj9bJ7rv8qOMAII7SL3">/files/bFj9bJ7rv8qOMAII7SL3</a></td><td><a href="/pages/ACUF6I6ykXCpaJqs4csm#getting-started-basic-usage">/pages/ACUF6I6ykXCpaJqs4csm#getting-started-basic-usage</a></td></tr><tr><td></td><td align="center"><strong>Advanced usage</strong></td><td></td><td><a href="/files/VUJsCdie24uH1M2Up8Vk">/files/VUJsCdie24uH1M2Up8Vk</a></td><td><a href="/pages/ACUF6I6ykXCpaJqs4csm#advanced-usage">/pages/ACUF6I6ykXCpaJqs4csm#advanced-usage</a></td></tr><tr><td></td><td align="center"><strong>Frequently Asked Questions</strong></td><td></td><td><a href="/files/KY7KscsTH3h3TIdqsykd">/files/KY7KscsTH3h3TIdqsykd</a></td><td><a href="/pages/ACUF6I6ykXCpaJqs4csm#faq">/pages/ACUF6I6ykXCpaJqs4csm#faq</a></td></tr><tr><td></td><td align="center"><strong>API Reference</strong></td><td></td><td><a href="/files/jpNU8GYrp0jeA1wxdg8E">/files/jpNU8GYrp0jeA1wxdg8E</a></td><td><a href="/pages/NUpVhVogbFjND6MXXlAE">/pages/NUpVhVogbFjND6MXXlAE</a></td></tr></tbody></table>

***

***

## Installation

***

1. To get started with installing *catch22* in MATLAB, clone the repository to a location of your choice using the following command in `Bash/CMD`:

```bash
git clone https://github.com/DynamicsAndNeuralSystems/catch22.git
```

2. In MATLAB, navigate to the `wrap_MATLAB` directory in the cloned repo and call `mexAll` from the MATLAB command window. Ensure you include the folder in your MATLAB path to use the package:

```matlab
cd('catch22/wrap_MATLAB')
addpath('catch22/wrap_MATLAB') % add folder in MATLAB path
mexAll 
```

***

## Getting Started: Basic Usage

Here we outline how you can jump straight into computing *catch22* features on your time series data with a basic usage example.

### Expected Input

*catch22* MATLAB only accepts one univariate time series at a time, with the input being passed in as a **column vector.** Consider the following example for a single time series of length 10 (i.e., 10 points):

```matlab
>> data = rand(10,1)
% example of the expected format for your time series data
data =
    0.5672
    0.9982
    0.1319
    ...
    0.0813
    0.6592
```

### Computing *catch22* features

All features are bundled into a function called `catch22_all`. By default, the extended *catch24* feature set will be computed unless a boolean flag which corresponds to the argument `doCatch24` (which can either be set to `true` or `false)` is used in the function call:&#x20;

* `true` -> return the *catch24* feature set (*catch22* + mean + std. dev.).
* `false` -> return the standard *catch22* feature set.

```matlab
% compute catch24 features
[vals, names] = catch22_all(data);
% for the catch22 feature set
[vals, names] = catch22_all(data, false);
```

### Expected output

An **array** of feature outputs and a **cell** of feature names (`24x1` if *catch24*, `22x1` if *catch22*) will be returned by MATLAB. The order in which the feature outputs are returned corresponds to the order in which feature names are returned, e.g., the feature output in `vals(1)` corresponds to the feature name `names(1)`:

```matlab
% Print feature name and value
for i = 1:size(names,1)
    fprintf('%s: %f\n', names{i}, vals(i));
end
```

And that's it! You now have all the knowledge you need to apply *catch22* to your time series data. To access some of the additional functionality of *catch22*, keep reading for advanced usage tips and examples.

***

***

## Advanced Usage

Ready to explore some of the additional functionality of *catch22*? Here we provide a usage guide for some of the &#x20;

### 1. *Catch24*

If the location and spread of the raw time series distribution may be important for your application, you can enable *catch24.*

{% tabs %}
{% tab title="Catch24" %}
*Catch24* is an extension of the original *catch22* feature set to include **mean** and **standard deviation,** yielding a total of **24** time series features. In MATLAB, users can enable the *catch24* feature set by passing the boolean flag `true` into the `catch22_all` function call:

```matlab
tsData = rand(100,1) % create some time series
[vals, names] = catch22_all(tsData, true)
```

{% endtab %}
{% endtabs %}

### 2. Computing Individual Features

If you do not wish to compute the full *catch22* feature set on your time series, you can alternatively compute each feature (including mean and std. deviation) individually.

{% tabs %}
{% tab title="Computing Individual Features" %}
To compute individual features in MATLAB, you can call the corresponding function given by `catch22_{featureName}` where `featureName` is the feature's long name (as in the [feature overview table](/catch22/information-about-catch22/feature-descriptions/feature-overview-table.md)). For example, `catch22_DN_HistogramMode_5` can be called to compute the feature [`DN_HistogramMode_5`](/catch22/information-about-catch22/feature-descriptions/linear-autocorrelation-structure.md). You can retrive all feature names by calling `GetAllFeatureNames.`

As an example, let's compute only the feature `DN_HistogramMode_5` on a single univariate time series:

```matlab
tsData = rand(1, 1000) % create length 1000 time series
f = catch22_DN_HistogramMode_5(tsData) % returns a double
fprintf('DN_HistogramMode_5 value: %f\n', f) 
```

Note that here we pass our time series as a **row vector** (`1x1000`) to the individual feature function. On the other hand, the `catch22_all` function for computing the entire feature set only accepts time series as a **column vector** (`1000x1`)**.**&#x20;
{% endtab %}
{% endtabs %}

### 3. Short Names

For each feature, we also include a unique 'short name' for easier reference (as outlined in the [feature overview table](/catch22/information-about-catch22/feature-descriptions/feature-overview-table.md)).&#x20;

{% tabs %}
{% tab title="Short Names" %}
In MATLAB, short names can be included in the output when calling `catch22_all` by specifying an additional output:

```python
tsData = rand(1000, 1) % your time series data
[feature_vals, long_names, short_names] = catch22_all(tsData, false)
% print the short name and corresponding feature value
for i=1:size(feature_vals, 1):
    fprintf("%s : %f\n", short_names{i}, feature_vals(i))
end
```

Now, in addition to the cell of long names and feature values, we also obtain an additional cell (`22x1` for *catch22,* `24x1` for *catch24*) of short feature names.&#x20;
{% endtab %}
{% endtabs %}

***

## FAQ

Click one of the expandable tabs below to explore commonly asked questions about *pycatch22* in MATLAB:

<details>

<summary>How can I submit a bug report for c<em>atch22?</em> </summary>

If you would like to submit a bug report, you can access our Bug Tracker [here](https://github.com/DynamicsAndNeuralSystems/catch22/issues). For guidelines on submitting an ideal bug report, see our page on [contributing to *catch22*](/catch22/information-about-catch22/contributing-to-catch22.md)*.*&#x20;

</details>

***

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://time-series-features.gitbook.io/catch22/language-specific-docs/matlab.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
