-
Notifications
You must be signed in to change notification settings - Fork 0
/
Katz_FD.m
51 lines (43 loc) · 1.69 KB
/
Katz_FD.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function [KFD] = Katz_FD(serie)
%{
Script for computing the Katz Fractal Dimension (KFD).
INPUT:
serie: is the temporal series that one wants to analyze by KFD.
It must be a row vector.
OUTPUT:
KFD: the KFD of the temporal series.
TIP: the KFD of a straight line must be exactly 1. Otherwise, the
implementation of the algorithm is wrong.
PROJECT: Research Master in signal theory and bioengineering - University of Valladolid
DATE: 08/07/2014
AUTHOR: Jesús Monge Álvarez
%}
%% Checking the ipunt parameters:
control = ~isempty(serie);
assert(control,'The user must introduce a series (first inpunt).');
%% Processing:
% Computing 'L':
% 'L' is the total length of the curve, that is to say, the sum of the
% distance between succesive points. The distance between two points of the
% waveform is defined as the Ecludian distance: dist(s1,s2) = sqrt[(x1-x2)^2 + (y1 - y2)^2];
% For this case: (x1 - x2) = 1 for all samples.
L = 0;
N = length(serie);
n = N - 1; %'n' is the number of steps in the waveform.
for i = 1:(N - 1)
aux = sqrt(1 + ((serie(i) - serie(i+1))^2));
L = L + aux;
clear('aux');
end
% Computing 'd':
% 'd' is the planar extent or diameter of the waveform. It is estimated as
% the distance between the first point of the sequence and the point of the
% sequence that provides the farthest distance: d = max(dist(1,i)); i=2...N.
dist = NaN(1,N-1); %Predifinition variable for computatinoal efficiency.
for i = 2:N
dist(i) = sqrt(((1 - i)^2) + ((serie(1) - serie(i))^2));
end
d = max(dist);
% Computing of KFD:
% The KFD is computed as follows: KFD = log10(n) / [log10(n) + log10(d/L)];
KFD = log10(n)/(log10(n) + log10(d/L));