-
Notifications
You must be signed in to change notification settings - Fork 11
/
eha_gss.m
54 lines (41 loc) · 1.1 KB
/
eha_gss.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
function p = eha_gss( t, s)
%EHA_GSS - Find a first guess for the parameters of the Eden and Hazel model
%
% Syntax: p = eha_gss( t, s)
%
% t = measured time
% s = measured drawdown
% p = first guess for the parameters
%
% Description:
% First guess for the parameters of Eden and Hazel solution
%
% See also: eha_dmo, eha_pre, eha_dim, eha_rpt
%
global EHA_MATRIX
if( isempty(EHA_MATRIX) ) % NE MARCHE PAS - TROUVER UNE SOLUTION !
disp(' ERROR: eha_dim: You must run EHA_PRE before using the eha model')
return;
end
d=EHA_MATRIX;
% Principle: a straight line is fitted to the last step
% for the other steps, we take the same slope
% and adjust the Ai so that we pass through the
% last point of the step
% Number of steps (pumping periods)
ns=d(end,2);
% Finding the points of the last period
l=find(d(:,2)==ns);
X=d(l(4:end),1);
Y=s(l(4:end));
% Linear least-squares fit
g=[X,ones(size(X,1),1)];
r=inv(g'*g)*g'*Y;
a=r(1);
% Values at the origin for all the steps
for i=1:ns
l=find(d(:,2)==i);
A(i)=s(l(end))-a.*d(l(end));
end
% Assembling the results
p=[a,A];