-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathembed.m
45 lines (40 loc) · 1.08 KB
/
embed.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
function y = embed(varargin)
% EMBED Create embedding vector.
% Y = EMBED(X, M, T) creates embedding vector Y from
% time series X using a time delay embedding with
% dimension M and time delay T. The resulting embedding
% vector has length N-T*(M-1), where N is the length
% of the original time series.
%
% Example: x = sin(0:0.1:10*2*pi);
% y = embed(x,2,16);
% plot(y(:,1),y(:,2))
% Copyright (c) 2021-
% Norbert Marwan, Potsdam Institute for Climate Impact Research, Germany
% http://www.pik-potsdam.de
%
% $Date: $
% $Revision: $
%
%
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or any later version.
%% check input arguments
error(nargchk(1,3,nargin))
error(nargoutchk(0,1,nargout))
if nargin < 3
tau = 1;
else
tau = varargin{3};
end
if nargin < 2
m = 2;
else
m = varargin{2};
end
x = varargin{1}(:);
N = length(x) - (m-1)*tau;
y = buffer(x,N,N-tau,'nodelay');