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
|
N_ports = 0;
for i=1:n_ports # Count the true number of ports.
[subport,n_sub] = split_port(port_list(i,:), ',');
N_ports = N_ports+n_sub;
end;
[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,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);
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
|
|
>
>
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
|
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
|
N_ports = 0;
for i=1:n_ports # Count the true number of ports.
[subport,n_sub] = split_port(port_list(i,:), ',');
N_ports = N_ports+n_sub;
end;
[bonds,components,n_vector_bonds] = rbg2abg(name,rbonds,rstrokes,rcomponents,port_coord,port_name,\
infofile,errorfile);
%Write the function m-file for the causal bond graph
write_abg(name,bonds,components,n_vector_bonds);
# filename = '$1_abg.m';
# filenum = fopen(filename,'w');
# c = '%';
# fprintf(filenum, 'function [bonds,components,n_ports,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);
# fprintf(filenum, 'N_ports = %1.0f;\n', N_ports);
EOF
# Append any VAR declarations
if [ -f "$1_lbl.txt" ]; then
echo "# Explicit variable declarations" >> $1_abg.m
grep '^[\s]*[%|#]VAR' $1_lbl.txt | tr '%' '#' >> $1_abg.m
fi
## Close off the function
echo "endfunction" >> $1_abg.m
## Errors and info
if [ "$info" = "info" ]; then
cat mtt_info.txt
fi
if mtt_error mtt_error.txt
then
exit 0
|