mdwtcluster
Multisignals 1-D clustering
Description
clusters data using hierarchical clustering. The input matrix s
= mdwtcluster(x
)x
is
decomposed in the row direction using the discrete wavelet transform (DWT) with the Haar
wavelet and the maximum allowed level fix(log2(size(x,2)))
.
Note
mdwtcluster
requires Statistics and Machine Learning Toolbox™.
specifies options using name-value pair arguments in addition to the input argument in the
previous syntax. For example, s
= mdwtcluster(___,Name,Value
)'level',4
specifies the decomposition
level.
Examples
Cluster 1-D Multisignal
Load the 1-D multisignal elecsig10
.
load elecsig10
Compute the structure resulting from multisignal clustering.
lst2clu = {'s','ca1','ca3','ca6'}; S = mdwtcluster(signals,'maxclust',4,'lst2clu',lst2clu)
S = struct with fields:
IdxCLU: [70x4 double]
Incons: [69x4 double]
Corr: [0.7920 0.7926 0.7947 0.7631]
Retrieve the cluster indices.
IdxCLU = S.IdxCLU;
Plot the first and third clusters.
plot(signals(IdxCLU(:,1)==1,:)','r') hold on plot(signals(IdxCLU(:,1)==3,:)','b') hold off title('Cluster 1 (Signal) and Cluster 3 (Coefficients)')
Check the equality of partitions. Confirm we obtain the same partitions using coefficients of approximation at level 3 instead of the original signals. Much less information is then used.
equalPART = isequal(IdxCLU(:,1),IdxCLU(:,3))
equalPART = logical
1
Input Arguments
x
— Input data
matrix
Input data, specified as a matrix.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
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.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: s = mdwtcluster(signals,'maxclust',4,'wname','db4')
specifies
four clusters and the wavelet db4
.
dirDec
— Direction of decomposition
'r'
(default) | 'c'
Direction of decomposition, specified as 'r'
(row) or
'c'
(column).
level
— Level of DWT decomposition
fix(log2(size(x
,d)))
(default) | positive integer
x
,d)))Level of DWT decomposition, specified as a positive integer. The default value is
fix(log2(size(
, where
x
,d)))d=1
or d=2
, depending on the
dirDec
value.
wname
— Wavelet
'haar'
(default) | character vector | string scalar
Wavelet used for the DWT, specified as a character vector or string scalar. The
default value is the Haar wavelet, 'haar'
.
dwtEXTM
— DWT extension mode
character vector | string scalar
DWT extension mode, specified as a character vector or string scalar. See
dwtmode
.
pdist
— Distance metric
'euclidean'
(default) | character vector | string scalar | function handle
Distance metric, specified as a character vector, string scalar, or function
handle. The default value is 'euclidean'
. See pdist
(Statistics and Machine Learning Toolbox).
linkage
— Algorithm for computing the distance between clusters
'ward'
(default) | 'average'
| 'centroid'
| 'complete'
| ...
Algorithm for computing the distance between clusters, specified as one of the values in this table.
Method | Description |
---|---|
'average' | Unweighted average distance (UPGMA) |
'centroid' | Centroid distance (UPGMC), appropriate for Euclidean distances only |
'complete' | Farthest distance |
'median' | Weighted center of mass distance (WPGMC), appropriate for Euclidean distances only |
'single' | Shortest distance |
'ward' | Inner squared distance (minimum variance algorithm), appropriate for Euclidean distances only |
'weighted' | Weighted average distance (WPGMA) |
See linkage
(Statistics and Machine Learning Toolbox).
maxclust
— Number of clusters
6 (default) | integer | vector
Number of clusters, specified as an integer or vector.
lst2clu
— Cell array that contains the list of data to classify
cell array | string vector
Cell array of character vectors or string vector which contains the list of data to classify. If N is the level of decomposition, the allowed name values for the cells are:
's'
— Signal'aj'
— Approximation at level j'dj'
— Detail at level j'caj'
— Coefficients of approximation at level j'cdj'
— Coefficients of detail at level j
with j = 1, …,
N
.
The default value is {'s';'ca1';...;'caN'}
or ["s" "cal" ... "caN"]
.
Output Arguments
s
— Output structure
structure
The output structure s
is such that for each partition
j:
S.Idx(:,j) | Contains the cluster numbers obtained from the hierarchical cluster
tree. See |
S.Incons(:,j) | Contains the inconsistent values of each non-leaf node in the
hierarchical cluster tree. See |
S.Corr(j) | Contains the cophenetic correlation coefficients of the partition.
See |
Note
If maxclust
is a vector, then IdxCLU
is a
multidimensional array such that
IdxCLU(:,j,k)
contains
the cluster numbers obtained from the hierarchical cluster tree for
k clusters.
Version History
Introduced in R2008a
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)