-
Notifications
You must be signed in to change notification settings - Fork 42
/
min_delta.m
executable file
·44 lines (36 loc) · 1.38 KB
/
min_delta.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
% MIN_DELTA - Computes the minimum change in the parameter lambda
% that causes one of the parameters psi(k) to change from
% the given initial value to the given final value.
% Only the parameters with flags(k) = 1 are checked.
% psi(k) and lambda are assumed to be linearly related.
%
% Syntax: [min_d,k] = min_delta(flags,psi_initial,psi_final,psi_sens)
%
% flags: parameters to check
% min_d: minimum change in lambda
% k: parameter psi_k that achieves psi_final_k
% psi_initial: initial values for the parameters psi_i
% psi_final: final values for the parameters psi_i
% psi_sens: parameter sensitivities (d(psi_i)/d(lambda))
%
% Version 3.22e -- Comments to [email protected]
%
function [min_d,k] = min_delta(flags,psi_initial,psi_final,psi_sens)
if (any(flags))
% find the parameters to check
ind = find(flags);
deltas = (psi_final(ind)-psi_initial(ind))./psi_sens(ind);
[min_d,i] = min(deltas);
k = ind(i);
% if there is more than one parameter that achieves the final value
% with min_delta, select the parameter with the highest
% sensitivity |psi_sens|
min_k = find(deltas == min_d);
if (length(min_k) > 1)
[max_sens,i] = max(abs(psi_sens(ind(min_k))));
k = ind(min_k(i));
end;
else
min_d = Inf;
k = -1;
end;