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
|
#Inform user
echo Creating $1_abg.m
# Use matrix manipulation to accomplish the transformation
$MATRIX > rbg2abg_m.log 2>mtt_error.txt << EOF
name = '$1'
infofile = 'mtt_info.txt';
%Convert from the fig version of the bonds to a structured version
[rbonds,rstrokes,rcomponents,port_coord,port_name,port_list] = $1_rbg;
[n_ports, junk] = size(port_list);
[bonds,components] = rbg2abg(name,rbonds,rstrokes,rcomponents,port_coord,port_name,infofile);
%Write the function m-file for the causal bond graph
filename = '$1_abg.m';
filenum = fopen(filename,'w');
c = '%';
fprintf(filenum, 'function [bonds,components,n_ports] = $1_abg\n');
fprintf(filenum, '%s [bonds,components,n_ports] = $1_abg\n', c);
fprintf(filenum, '%s Acausal bond graph created by MTT on %s\n\n', ...
c, date);
mat2mfile(bonds, 'bonds', filenum);
mat2mfile(components, 'components', filenum);
fprintf(filenum, 'n_ports = %1.0f;\n', n_ports);
EOF
if [ "$info" = "info" ]; then
cat mtt_info.txt
fi
mtt_error mtt_error.txt
|
>
|
>
>
|
>
>
>
>
>
|
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
|
#Inform user
echo Creating $1_abg.m
# Use matrix manipulation to accomplish the transformation
$MATRIX > rbg2abg_m.log 2>mtt_error.txt << EOF
name = '$1'
infofile = 'mtt_info.txt';
errorfile = 'mtt_error.txt';
%Convert from the fig version of the bonds to a structured version
[rbonds,rstrokes,rcomponents,port_coord,port_name,port_list] = $1_rbg;
[n_ports, junk] = size(port_list);
[bonds,components] = rbg2abg(name,rbonds,rstrokes,rcomponents,port_coord,port_name,\
infofile,errorfile);
%Write the function m-file for the causal bond graph
filename = '$1_abg.m';
filenum = fopen(filename,'w');
c = '%';
fprintf(filenum, 'function [bonds,components,n_ports] = $1_abg\n');
fprintf(filenum, '%s [bonds,components,n_ports] = $1_abg\n', c);
fprintf(filenum, '%s Acausal bond graph created by MTT on %s\n\n', ...
c, date);
mat2mfile(bonds, 'bonds', filenum);
mat2mfile(components, 'components', filenum);
fprintf(filenum, 'n_ports = %1.0f;\n', n_ports);
EOF
if [ "$info" = "info" ]; then
cat mtt_info.txt
fi
if mtt_error mtt_error.txt
then
exit 0
else
exit 1
fi
|