Overview
Comment:Now generates header using lang_header
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: dffeaface9fbcc5cce68153f85da07d8f3dc770d8f611cbe56742e5f8e60f834
User & Date: gawthrop@users.sourceforge.net on 1999-01-20 22:13:13
Other Links: branch diff | manifest | tags
Context
1999-01-20
22:19:21
Puts emacs mode line at top of .m files check-in: 8af8b50c46 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
22:13:13
Now generates header using lang_header check-in: dffeaface9 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
1998-12-14
15:27:32
Added separate handling of ports ( poss zero) check-in: 16b65ab26f user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/obs_r2m from [331b294f53] to [f6c0999a75].

11
12
13
14
15
16
17





18
19
20
21
22
23
24

# Inform user
echo Creating $1_obs.m

# Remove the old log file
rm -f obs_r2m.log
rm -f $1_obs.m?






# Use reduce to accomplish the transformation
$SYMBOLIC >obs_r2m.log << EOF

%Read the reduce definitions file
in "$1_def.r";








>
>
>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

# Inform user
echo Creating $1_obs.m

# Remove the old log file
rm -f obs_r2m.log
rm -f $1_obs.m?
rm -f $1_obsa.m

# Is the system affine (look in the _obs.r file
affine=`grep 'affine :=' $1_obs.r | awk '{print $3}' | sed 's/;//'`


# Use reduce to accomplish the transformation
$SYMBOLIC >obs_r2m.log << EOF

%Read the reduce definitions file
in "$1_def.r";

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

ON BigFloat, NumVal;
PRECISION 16; %Compatible with Matlab
OFF Nat;

ON NERO;        % Suppress zero elements

mtt_matrix := MTTYY;
mtt_matrix_n := MTTNY*(MTTGPCNy+1);
mtt_matrix_m := 1;
mtt_matrix_name := Y;
in"$MTTPATH/trans/matlab_matrix.r";

OUT "$1_obs.m1";

write "function Y = $1_obs(x,u)";
write "%GPC O function in matlab form for system $1;;";
write "%File $1_obs.m;;";
write "%Generated by MTT;;";

write "%"; 
write "% Set up the State variables";
FOR i := 1:MTTNx DO
BEGIN
  write "mttx", i, " = x(", i, ");";
END;



write "%"; 
write "% Set up the inputs and input derivatives";
FOR i := 1:MTTNu DO
  BEGIN
    write "mttu", i, " = u(", i, ",1);";
    FOR j := 1:MTTGPCNu DO
    BEGIN
      write "mttu", i,j, " = u(", i, ",", j+1, ");";
    END;
  END;

write "%"; 
write "% Set up the Y matrix";
write "Y = zeros(", mtt_matrix_n, ",1);";



SHUT "$1_obs.m1";



GENTRANOUT "$1_obs.m3";






write "%"; 






write "% Translate the expression for Y";









matlab_matrix(); 

GENTRANSHUT "$1_obs.m3";


EOF

# Create the globals


sympar2global_txt2m $1> $1_obs.m2


# Change name
echo 'Y = mtt_matrix;' > $1_obs.m4
# Put together the pieces

cat   $1_obs.m? >$1_obs.m

rm -f $1_obs.m?














|
<
<
<


|

<
<
<
<
<
<






>
>











|
|
|
>


|

>
>
|
>
>
>
>
>
>
|
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
|
>
|
>



|
>
>
|
>

<
<

>



>
>
>
>



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

ON BigFloat, NumVal;
PRECISION 16; %Compatible with Matlab
OFF Nat;

ON NERO;        % Suppress zero elements

% Matrix output function



in"$MTTPATH/trans/matlab_matrix.r";

OUT "$1_obs.m2";







write "% Set up the State variables";
FOR i := 1:MTTNx DO
BEGIN
  write "mttx", i, " = x(", i, ");";
END;

IF affine=0 THEN 
BEGIN
write "%"; 
write "% Set up the inputs and input derivatives";
FOR i := 1:MTTNu DO
  BEGIN
    write "mttu", i, " = u(", i, ",1);";
    FOR j := 1:MTTGPCNu DO
    BEGIN
      write "mttu", i,j, " = u(", i, ",", j+1, ");";
    END;
  END;

%write "%"; 
%write "% Set up the Y matrix";
%write "Y = zeros(", mtt_matrix_n, ",1);";
END;


SHUT "$1_obs.m2";

IF affine=1 THEN 
BEGIN
  GENTRANOUT "$1_obs.m3";
  MTT_Matrix := MTTObs_o$ 
  MTT_Matrix_name := "MTTO_o"$
  MTT_Matrix_n := (MTTGPCNY+1)*MTTNy$
  MTT_Matrix_m := 1$
  matlab_Matrix()$
  GENTRAN O_o := mtt_matrix;

  MTT_Matrix := MTTObs_h$ 
  MTT_Matrix_name := "MTTO_h"$
  MTT_Matrix_n := (MTTGPCNy+1)*MTTNy$
  MTT_Matrix_m := (MTTGPCNu+1)*MTTNu$
  matlab_Matrix()$
  GENTRAN O_h := mtt_matrix;

  GENTRANSHUT "$1_obs.m3";
END
ELSE
BEGIN
  GENTRANOUT "$1_obs.m3";
  mtt_matrix := MTTYY$
  mtt_matrix_n := MTTNY*(MTTGPCNy+1)$
  mtt_matrix_m := 1$
  mtt_matrix_name := Y$
  matlab_matrix(); 
  GENTRAN YY := mtt_matrix;
  GENTRANSHUT "$1_obs.m3";
END;

EOF

if [ "$affine" = "1" ]; then
    lang_header $1 obs m x [o_o,o_h] > $1_obs.m1
else
    lang_header $1 obs m x,u yy > $1_obs.m1
fi



# Put together the pieces
matlab_tidy $1_obs.m3
cat   $1_obs.m? >$1_obs.m

rm -f $1_obs.m?








MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]