FINDCHANGEPTS finds abrupt changes in a signal
  IPOINT = FINDCHANGEPTS(X) returns the index in X that corresponds to
  the most significant change in mean.
 
  If X is a vector with N elements, FINDCHANGEPTS partitions X into two
  regions, X(1:IPOINT-1) and X(IPOINT:N), that minimize the sum of the
  residual (squared) error of each region from its local mean.
 
  If X is an M-by-N matrix, FINDCHANGEPTS partitions X into two regions,
  X(1:M,1:IPOINT-1) and X(1:M,IPOINT:N), returning the columnar index that
  minimizes the sum of the residual error of each region from its local
  (M-dimensional) mean.
 
  IPOINTS = FINDCHANGEPTS(..., 'MaxNumChanges', Kmax) returns the largest
  number of significant changes, not exceeding Kmax, that minimize the sum
  of the residual error and an internal fixed penalty for each change.  The
  indices of the changes are returned in IPOINTS.  IPOINTS is empty if no
  significant changes less than or equal to Kmax are detected.  If Kmax is
  empty or unspecified, FINDCHANGEPTS will always return one changepoint.
 
  IPOINTS = FINDCHANGEPTS(..., 'Statistic', STAT) specifies the type of
  change to detect.  The default is 'mean':
     'mean'   detect changes in mean
     'rms'    detect changes in root-mean-square level
     'std'    detect changes in standard deviation
     'linear' detect changes in mean and slope
 
  IPOINTS = FINDCHANGEPTS(..., 'MinDistance', Lmin) specifies the minimum
  allowable number of samples, Lmin, between changepoints.  If unspecified,
  Lmin will be 1 for changes in mean, and 2 for other changes.
 
  IPOINTS = FINDCHANGEPTS(..., 'MinThreshold', BETA) specifies the minimum
  improvement in total residual error for each changepoint.  If specified,
  FINDCHANGEPTS finds the smallest number of changes that minimizes the sum
  of the residual error with an additional penalty of BETA for each change.
  'MinThreshold' cannot be specified with the 'MaxNumChanges' parameter.
 
  [IPOINTS, RESIDUAL] = FINDCHANGEPTS(...) additionally returns the
  residual error of signal against the modeled changes.
 
  FINDCHANGEPTS(...) without output arguments plots the signal and the
  detected change point(s).
 
    % Example 1:
    %   Find the most significant change in mean
    load('meanshift.mat','x')
    findchangepts(x)
 
    % Example 2:
    %   Find the 12 most significant changes in linear regression of
    %   engine speed.
    load('engineRPM.mat','x')
    findchangepts(x,'Statistic','linear','MaxNumChanges',12)
 
    % Example 3:
    %   Find the smallest number of changes in linear regression
    %   applying a penalty to each change by the variance of the signal.
    load('engineRPM.mat','x')
    findchangepts(x,'Statistic','linear','MinThreshold',var(x))
 
    % Example 4:
    %   Partition a handwriting sample into a small number of segments
    %   that occupy roughly the same position in space.
    load('cursiveex.mat','data')
    x = [real(data); imag(data)];
    findchangepts(x,'MaxNumChanges',20)
 
    % Example 5:
    %   Break a handwriting sample into a small number of segments
    %   that are piecewise linear
    load('cursiveex.mat','data')
    x = [real(data); imag(data)];
    findchangepts(x,'Statistic','linear','MaxNumChanges',100)
 
    % Example 6:
    %   Find the locations where the power changes in the
    %   spectrogram of a of a train whistle
    load('train.mat','y','Fs')
    [S,F,T,Pxx] = spectrogram(y,128,120,128,Fs);
    findchangepts(pow2db(Pxx),'MaxNumChanges',10)
 
    See also CUSUM, FINDPEAKS.
    Documentation for findchangepts
       doc findchangepts