-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathoswzerob.m
57 lines (52 loc) · 2.02 KB
/
oswzerob.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
function oswzerob(fid,th0,params,lpars,fmts)
% OSWZEROB(fid,th0,params,lpars,fmts)
%
% Writes the (b)eginning of a THZRO diagnostic file
%
% INPUT:
%
% fid The file id (from OSOPEN)
% th0 The parameter vector (see, e.g., SIMULOS)
% params A structure with the known constants (see, e.g. SIMULOS)
% lpars lpars{1} not written out here, but rather by OSWDIAG
% lpars{2} not written out here, but rather by OSWDIAG
% lpars{3} not written out here, but rather by OSWDIAG
% lpars{4} not written out here, but rather by OSWDIAG
% lpars{5} not written out here, but rather by OSWDIAG
% lpars{6} the options used by the FMINUNC/FMINCON procedure
% lpars{7} any bounds used by the FMINUNC/FMINCON procedure
% lpars{8} not written out here, but rather by OSWDIAG
% fmts Cell array with format strings from OSOPEN
%
% SEE ALSO:
%
% OSWZEROE, OSRZERO, OSWDIAG, OSRDIAG
%
% Last modified by fjsimons-at-alum.mit.edu, 06/25/2018
% Commit the truth to file
fprintf(fid,'%s\n','the true parameter vector');
fprintf(fid,fmts{1},th0);
% Commit the parameters of the experiment to file
fprintf(fid,'%s\n','the fixed experimental parameters');
% Rather, these need to be ordered to yield to the format
fulls={'DEL','g','z2','dydx','NyNx','blurs','kiso','quart'};
[~,i]=ismember(fulls,fieldnames(params));
jk=struct2cell(params);
fprintf(fid,fmts{2},[jk{i(~~i)}]);
% Convert the bounds to something printable
fprintf(fid,'%s\n','the bounds, if any');
if ~isempty(lpars{7})
struct2str(cell2struct(lpars{7},...
{'A', 'B' ,... % Linear Inequalities
'Aeq','Beq',... % Linear Equalities
'LB',... % Lower Bounds
'UB',... % Upper Bounds
'NONLCON'},... % Nonlinear Inequalities
2),fid);
else
% We need at least one colon on the next line
struct2str(cell2struct({'None'},{'Bounds'},2),fid)
end
% Commit the parameters of the optimization to file
fprintf(fid,'%s\n','the optimization options');
struct2str(lpars{6},fid)