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
|
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
|
+
+
+
-
-
+
-
-
-
-
-
-
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
+
|
function makedef(structure,deffile);
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.2 1996/08/18 20:05:20 peter
% %% Put unded version control
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargin<2
deffile = 'stdout';
filenum = fopen(deffile,'w');
end;
states = structure(1);
nonstates=structure(2);
inputs=structure(3);
outputs=structure(4);
zero_outputs = structure(5);
pc = '%';
% Declare reduce constants;
fprintf(deffile, 'MTTNx := %1.0f;\n', states);
fprintf(deffile, 'MTTNz := %1.0f;\n', nonstates);
fprintf(deffile, 'MTTNu := %1.0f;\n', inputs);
fprintf(deffile, 'MTTNy := %1.0f;\n', outputs);
fprintf(deffile, 'MTTNyz := %1.0f;\n', zero_outputs);
fprintf(filenum, 'MTTNx := %1.0f;\n', states);
fprintf(filenum, 'MTTNz := %1.0f;\n', nonstates);
fprintf(filenum, 'MTTNu := %1.0f;\n', inputs);
fprintf(filenum, 'MTTNy := %1.0f;\n', outputs);
fprintf(filenum, 'MTTNyz := %1.0f;\n', zero_outputs);
% Declare reduce matrices
fprintf(deffile, '%s Declare reduce matrices\n', pc);
fprintf(filenum, '%s Declare reduce matrices\n', pc);
if states>0
fprintf(deffile, 'matrix MTTx(%1.0f,1);\n', states);
fprintf(deffile, 'matrix MTTdx(%1.0f,1);\n', states);
fprintf(filenum, 'matrix MTTx(%1.0f,1);\n', states);
fprintf(filenum, 'matrix MTTdx(%1.0f,1);\n', states);
end;
if nonstates>0
fprintf(deffile, 'matrix MTTz(%1.0f,1);\n', nonstates);
fprintf(deffile, 'matrix MTTdz(%1.0f,1);\n', nonstates);
fprintf(filenum, 'matrix MTTz(%1.0f,1);\n', nonstates);
fprintf(filenum, 'matrix MTTdz(%1.0f,1);\n', nonstates);
end;
if inputs>0
fprintf(deffile, 'matrix MTTu(%1.0f,1);\n', inputs);
fprintf(filenum, 'matrix MTTu(%1.0f,1);\n', inputs);
end;
if outputs>0
fprintf(deffile, 'matrix MTTy(%1.0f,1);\n', outputs);
fprintf(filenum, 'matrix MTTy(%1.0f,1);\n', outputs);
end;
if zero_outputs>0
fprintf(deffile, 'matrix MTTyz(%1.0f,1);\n', zero_outputs);
fprintf(deffile, 'matrix MTTui(%1.0f,1);\n', zero_outputs);
fprintf(filenum, 'matrix MTTyz(%1.0f,1);\n', zero_outputs);
fprintf(filenum, 'matrix MTTui(%1.0f,1);\n', zero_outputs);
end;
% Make an Nx x Nx unit matrix
if states>0
fprintf(deffile, 'matrix MTTI(%1.0f,%1.0f);\n', states,states);
fprintf(filenum, 'matrix MTTI(%1.0f,%1.0f);\n', states,states);
for i = 1:states
fprintf(deffile, 'MTTI(%1.0f,%1.0f) := 1;\n', i, i);
fprintf(filenum, 'MTTI(%1.0f,%1.0f) := 1;\n', i, i);
end
end;
% Set the y, yz, u, x and dx matrices
fprintf(deffile, '%s Set the y, yz, u and x matrices\n', pc);
fprintf(filenum, '%s Set the y, yz, u and x matrices\n', pc);
for i=1:outputs
fprintf(deffile, 'MTTy(%1.0f,1) := MTTy%1.0f;\n', i, i);
fprintf(filenum, 'MTTy(%1.0f,1) := MTTy%1.0f;\n', i, i);
end;
for i=1:zero_outputs
fprintf(deffile, 'MTTyz(%1.0f,1) := MTTyz%1.0f;\n', i, i);
fprintf(deffile, 'MTTui(%1.0f,1) := MTTui%1.0f;\n', i, i);
fprintf(filenum, 'MTTyz(%1.0f,1) := MTTyz%1.0f;\n', i, i);
fprintf(filenum, 'MTTui(%1.0f,1) := MTTui%1.0f;\n', i, i);
end;
for i=1:inputs
fprintf(deffile, 'MTTu(%1.0f,1) := MTTu%1.0f;\n', i, i);
fprintf(filenum, 'MTTu(%1.0f,1) := MTTu%1.0f;\n', i, i);
end;
for i=1:states
fprintf(deffile, 'MTTx(%1.0f,1) := MTTx%1.0f;\n', i, i);
fprintf(filenum, 'MTTx(%1.0f,1) := MTTx%1.0f;\n', i, i);
end;
for i=1:nonstates
fprintf(deffile, 'MTTdz(%1.0f,1) := MTTdz%1.0f;\n', i, i);
fprintf(filenum, 'MTTdz(%1.0f,1) := MTTdz%1.0f;\n', i, i);
end;
fprintf(filenum, 'END;');
fclose(filenum);
|