-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathideset.m
173 lines (165 loc) · 6.52 KB
/
ideset.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
function options = ideset(varargin)
%FCRKSET Create/alter DDE OPTIONS structure.
% OPTIONS = IDESET('NAME1',VALUE1,'NAME2',VALUE2,...) creates an integrator
% options structure OPTIONS in which the named properties have the
% specified values. Any unspecified properties have default values. It is
% sufficient to type only the leading characters that uniquely identify the
% property. Case is ignored for property names.
%
% OPTIONS = IDESET(OLDOPTS,'NAME1',VALUE1,...) alters an existing options
% structure OLDOPTS.
%
% OPTIONS = IDESET(OLDOPTS,NEWOPTS) combines an existing options structure
% OLDOPTS with a new options structure NEWOPTS. Any new properties
% overwrite corresponding old properties.
%
% IDESET with no input arguments displays all property names and their
% possible values.
%
%FCRKSET PROPERTIES
%
%RelTol - Relative error tolerance [ positive scalar {1e-3} ]
% This scalar applies to all components of the solution vector, and
% defaults to 1e-3 (0.1% accuracy). The estimated error in each
% integration step satisfies e(i) <= max(RelTol*abs(y(i)),AbsTol(i)).
%
%AbsTol - Absolute error tolerance [ positive scalar or vector {1e-6} ]
% A scalar tolerance applies to all components of the solution vector.
% Elements of a vector of tolerances apply to corresponding components of
% the solution vector. AbsTol defaults to 1e-6.
%
%NormControl - Control error relative to norm of solution [ on | {off} ]
% Set this property 'on' to request that the solver controls the error in
% each integration step with norm(e) <= max(RelTol*norm(y),AbsTol). By
% default the solver uses a more stringent component-wise error control.
%
%Events - Locate events [ function_handle ]
% To detect events, set this property to the event function.
%
%InitialStep - Suggested initial step size [ positive scalar ]
% The solver will try this first. By default the solver determines an
% initial step size automatically.
%
%MaxStep - Upper bound on step size [ positive scalar ]
% MaxStep defaults to one-tenth of the tspan interval.
%
%OutputFcn - Installable output function [ function_handle ]
% This output function is called by the solver after each time step. When
% the solver is called with no output arguments, OutputFcn defaults to
% @odeplot. Otherwise, OutputFcn defaults to [].
%
%OutputSel - Output selection indices [ vector of integers ]
% This vector of indices specifies which components of the solution vector
% are passed to the OutputFcn. OutputSel defaults to all components.
%
%Refine - Output refinement factor [ positive integer {1} ]
% This property increases the number of points passed to the OutputFcn
% after each integration step, resulting in a smoother output. Refine
% does not apply if length(TSPAN) > 2.
%
%Stats - Display computational cost statistics [ on | {off} ]
%
%InitialY - Initial value of solution [ vector ]
% By default the initial value of the solution is the value returned by
% HISTORY at the initial point. A different initial value can be supplied
% as the value of the InitialY property.
%
%Jumps - Discontinuities in solution [ vector ]
% Points t where the history or solution may have a jump discontinuity
% in a low order derivative. This property is available only in DDE23.
%
%BreakPoints - Breaking points in history [ vector ]
%
%BPOrders - Orders of breaking points in history [ vector of integers ]
%
%NumFlags - Number flags of history [ positive integer {1} ]
%
% See also FCRKGET, DDE23, DDESD, DDENSD, FUNCTION_HANDLE.
% Print out possible values of properties.
if (nargin == 0) && (nargout == 0)
fprintf(' AbsTol: [ positive scalar or vector {1e-6} ]\n');
fprintf(' BreakPoints: [ vector ]\n');
fprintf(' BPOrders: [ vector of integers ]\n');
fprintf(' Events: [ function_handle ]\n');
fprintf(' InitialStep: [ positive scalar ]\n');
fprintf(' InitialY: [ vector ]\n');
fprintf(' Jumps: [ vector ]\n');
fprintf(' MaxStep: [ positive scalar ]\n');
fprintf(' NormControl: [ on | {off} ]\n');
fprintf(' NumFlags: [ positive integer {1} ]\n');
fprintf(' OutputFcn: [ function_handle ]\n');
fprintf(' OutputSel: [ vector of integers ]\n');
fprintf(' Refine: [ positive integer {1} ]\n');
fprintf(' RelTol: [ positive scalar {1e-3} ]\n');
fprintf(' Stats: [ on | {off} ]\n');
fprintf(' IntEqs: [ vector ]\n');
fprintf('\n');
return;
end
Names = { 'AbsTol', 'BreakPoints', 'BPOrders', 'Events', 'InitialStep',...
'InitialY', 'IntEqs', 'Jumps', 'MaxStep', 'NormControl','NumFlags', 'OutputFcn', ...
'OutputSel', 'Refine', 'RelTol', 'Stats' };
m = length(Names);
% Combine all leading options structures o1, o2, ... in ddeset(o1,o2,...).
options = [];
for j = 1:m
options.(Names{j}) = [];
end
i = 1;
while i <= nargin
arg = varargin{i};
if ischar(arg) || (isstring(arg) && isscalar(arg)) % arg is an option name
break;
end
if ~isempty(arg) % [] is a valid options argument
if ~isa(arg,'struct')
error(message('MATLAB:fcrkget:NoPropNameOrStruct', i));
end
for j = 1:m
if any(strcmp(fieldnames(arg),Names{j}))
val = arg.(Names{j});
else
val = [];
end
if ~isempty(val)
options.(Names{j}) = val;
end
end
end
i = i + 1;
end
% Convert string arguments and options.
for ii = 1:nargin
if isstring(varargin{ii}) && isscalar(varargin{ii})
varargin{ii} = char(varargin{ii});
end
end
% A finite state machine to parse name-value pairs.
if rem(nargin-i+1,2) ~= 0
error(message('MATLAB:fcrkget:ArgNameValueMismatch'));
end
expectval = 0; % start expecting a name, not a value
while i <= nargin
arg = varargin{i};
if ~expectval
if ~ischar(arg)
error(message('MATLAB:fcrkget:PropNameNotString', i));
end
j = strncmpi(arg, Names, length(arg));
if ~any(j) % if no matches
error(message('MATLAB:fcrkget:InvalidPropName', arg));
elseif nnz(j) > 1 % if more than one match
% No names are subsets of others, so there will be no exact match
msg = strjoin(Names(j), ', ');
error(message('MATLAB:fcrkget:AmbiguousPropName', arg, msg));
end
expectval = 1; % we expect a value next
else
options.(Names{j}) = arg;
expectval = 0;
end
i = i + 1;
end
if expectval
error(message('MATLAB:fcrkget:NoValueForProp', arg));
end