-
Notifications
You must be signed in to change notification settings - Fork 5
/
tsLoglogExtrapolation.m
75 lines (46 loc) · 1.23 KB
/
tsLoglogExtrapolation.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
function [nx,ny,addedy]=tsLoglogExtrapolation(x,y,extrax,npoints)
%
% Extrapolates exponentiallytime series x,y to points extrax, according to the slope of the first/last number of points of the series (npoints)
%
% Michalis Vousdoukas 2016
[x,ii]=sort(x);
y=y(ii);
x=x(:);
y=y(:);
extrax=extrax(:);
nx=x;
ny=y;
clear x y
addedy=[];
if sum(extrax<nanmin(nx))>0
if sum(ny<=0)>0
offs=-min(ny)+1;
else
offs=0;
end
[nx0,ny0,addedy0]=tsLinearExtrapolation(log(nx),log(ny+offs),log(extrax(extrax<nanmin(nx))),npoints);
% plot(nx,ny,nx0,ny0,'r--')
nx=exp(nx0);
ny=exp(ny0)-offs;
addedy{1}=exp(addedy0{1})-offs;
% ny=[addedy ; ny];
% nx=[extrax ; nx];
end
if sum(extrax>nanmax(nx))>0
if sum(ny<=0)>0
offs=-min(ny)+1;
else
offs=0;
end
[nx0,ny0,addedy0]=tsLinearExtrapolation(log(nx),log(ny+offs),log(extrax(extrax>nanmax(nx))),npoints);
nx=exp(nx0);
ny=exp(ny0)-offs;
addedy{2}=exp(addedy0{2})-offs;
% ny=[y ; addedy];
% nx=[x ; extrax];
end
if iscell(addedy)
if length(addedy)==1
addedy=addedy{1};
end
end