-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathUpdateInitialConditions.m
More file actions
43 lines (40 loc) · 1.68 KB
/
UpdateInitialConditions.m
File metadata and controls
43 lines (40 loc) · 1.68 KB
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
%% Updates intitial conditions based of state variables available in the
% caller's namespace. Used for simulation continuation, outputs from *_heun()
% must exist and have their standard names.
%
% ARGUMENTS:
% options -- <description>
%
% OUTPUT:
% options-- <description>
%
% USAGE:
%{
<example-commands-to-make-this-function-run>
%}
%
% MODIFICATION HISTORY:
% SAK(<dd-mm-yyyy>) -- Original.
% SAK(05-08-2010 -- added conditional for not all state variables
% having delay.
% SAK(Nov 2013) -- Move to git, future modification history is
% there...
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function options = UpdateInitialConditions(options)
for SVj = 1:length(options.Dynamics.StateVariables),
try
ThisStateVariable = evalin('caller', options.Dynamics.StateVariables{SVj});
catch
sys_msg = lasterror.message;
error(['BrainNetworkModels:' mfilename ':Hackery'], ['This function expects parent namespace variables to be options.Dynamics.StateVariables']);
rethrow(sys_msg)
end
PreviousInitialConditions = options.Dynamics.InitialConditions.(options.Dynamics.StateVariables{SVj});
if size(PreviousInitialConditions,1)~=1, %there are time delays on this variable
CurrentState = cat(1,PreviousInitialConditions,ThisStateVariable);
options.Dynamics.InitialConditions.(options.Dynamics.StateVariables{SVj}) = CurrentState((end-options.Integration.maxdelayiters+1):end,:,:);
else
options.Dynamics.InitialConditions.(options.Dynamics.StateVariables{SVj}) = ThisStateVariable(end,:,:);
end
end
end %function UpdateInitialConditions()