%% Estimate Correlation Dimension in the Live Editor
% Use the Estimate Correlation Dimension task in the Live Editor to interactively estimate the correlation dimension of a uniformly sampled signal. Experiment with different values for lag, embedding dimension, similarity radius and number of points to align the linear fit line with the original data plot. The task automatically generates code reflecting your selections. Open this example to see a preconfigured script containing the Estimate Correlation Dimension task.
% For this example, consider 'corrDimData.mat' which contains reconstructed phase space signal phaseSpace.

load('corrDimData.mat','phaseSpace')

%
% To estimate the correlation dimension of the signal phaseSpace, open the Estimate Correlation Dimension in the Live Editor. On the Live Editor tab, select Task > Estimate Correlation Dimension. In the task, select signal phaseSpace.
%
% Since the selected signal is a phase space signal, select Phase space from the Signal Type dropdown menu.
%
%  The Estimate Correlation Dimension task creates the correlation dimension plot with default values for the similarity radius and the number of points.
%
% If your linear fit line does not align with the original data line using the default similarity radius values, try different values in the Similarity Radius Min, Similarity Radius Max and Number of Points fields until the alignment is satisfactory. For this example, use the minimum value of 0.08 and maximum value of 5 for the best alignment. The default value of 10 points provides good alignment for the signal phaseSpace.
%
% You can toggle displaying the output of the correlation dimension value in the Live Editor output using the Output Display option.
%
% The task generates code in your live script. The generated code reflects the parameters and options you specify. To see the generated code, click  at the bottom of the task parameter area. The task expands to display the generated code.
%
% By default, the generated code uses corrDim as the name of the output variable. To specify a different output variable name, enter a new name in the summary line at the top of the task. For instance, change the name to cDimension.
%
% The task updates the generated code to reflect the new variable name, and the new variable cDimension appears in the MATLAB workspace. The value of correlation dimension is directly proportional to the level of chaos in the system, that is, a higher value of cDimension represents a high level of chaotic complexity in the system.
% Copyright 2019 The MathWorks, Inc.