Index: mttroot/mtt/bin/trans/awk/lbl2cr.awk ================================================================== --- mttroot/mtt/bin/trans/awk/lbl2cr.awk +++ mttroot/mtt/bin/trans/awk/lbl2cr.awk @@ -10,10 +10,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.9 1998/03/08 21:01:40 peterg +## Now does multiple crs +## ## Revision 1.8 1998/03/06 09:15:28 peterg ## Ignores SS fields (assumes that if first field is a symbol then other ## field is and SS-style field. ## ## Revision 1.7 1997/04/22 12:50:15 peterg @@ -54,19 +57,20 @@ return matched; } BEGIN { -comment = "%"; +comment = "%|#"; cr_delimiter = ";"; not_a_cr = "effort flow state internal external zero none"; is_a_SS = "internal external zero"; numeric = "[0-9]"; symbolic = "\044"; # Ascii $ symbol_count = 0; symbols = ""; +# Include lin cr anyway. print "lin" } { if ( (match($1,comment)==0) && (NF>=3) ) { crs = $2 Index: mttroot/mtt/bin/trans/awk/lbl2sympar.awk ================================================================== --- mttroot/mtt/bin/trans/awk/lbl2sympar.awk +++ mttroot/mtt/bin/trans/awk/lbl2sympar.awk @@ -10,10 +10,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.13 1998/07/15 09:26:50 peterg +## Reinstated the second column of the sympar file - the system name +## ## Revision 1.12 1998/07/04 11:09:46 peterg ## Cleaned up - assumes new lbl style for SS ## ## Revision 1.11 1998/05/13 12:39:23 peterg ## Added `unknown' to list od names to avoid @@ -52,11 +55,11 @@ function exact_match(name1, name2) { return ((match(name1,name2)>0)&&(length(name1)==length(name2))) - } +} function matches(names, name) { n_matches = split(names,match_name); matched = 0; for (i_matches = 1; i_matches <= n_matches; i_matches++) { @@ -64,24 +67,27 @@ matched = 1; break; } } return matched; - } +} BEGIN { sys_name = ARGV[1]; -comment = "%"; +comment = "%|#"; +var = "[%|#]VAR"; arg_delimiter = ","; not_an_arg = "effort flow state internal external zero unknown 0 1"; SS_parameter = "internal external zero 0 1"; numeric = "[0-9-]"; symbol_count = 0; symbols = ""; } { + if (match($1,var)>0) print $2 "\t" name; + if ( (match($1,comment)==0) && (NF>=3) ) { n_args = split($3,arg,arg_delimiter); for (i = 1; i <= n_args; i++) { first_char = substr(arg[i],1,1); if ( (matches(not_an_arg,arg[i])==0) \ Index: mttroot/mtt/bin/trans/awk/tex2doc.awk ================================================================== --- mttroot/mtt/bin/trans/awk/tex2doc.awk +++ mttroot/mtt/bin/trans/awk/tex2doc.awk @@ -10,28 +10,32 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +# Revision 1.2 1997/04/15 11:18:49 peterg +# Uses supertabular package +# # Revision 1.1 1996/08/18 20:00:10 peter # Initial revision # ############################################################### -BEGIN { - split(ARGV[1],a,"_"); - system_name = a[1]; - split(a[2],b,"."); - representation = b[1]; - makefile = sprintf("%s_rep.make", system_name, representation); +END{ +# split(ARGV[1],a,"_"); +# system_name = a[1]; +# split(a[2],b,"."); +# representation = b[1]; + makefile = sprintf("%s_rep.make", $system_name, $representation); print "\\documentclass[12pt,a4paper]{article}"; printf("\\title{System %s, representation %s}\n", \ system_name, representation) print "\\author{Generated by MTT}"; print " \\usepackage{epsfig}"; print " \\usepackage{supertabular}"; print "\\begin{document}"; print " \\maketitle"; - printf(" \\input{%s_%s}\n", system_name, representation); + print" \\input{}", system_nam,e $representation; + print $system_name $representation print "\\end{document}" } Index: mttroot/mtt/bin/trans/m/cr2name.m ================================================================== --- mttroot/mtt/bin/trans/m/cr2name.m +++ mttroot/mtt/bin/trans/m/cr2name.m @@ -1,17 +1,34 @@ -function name = cr2name(RHS_number,LHS_cause,RHS_cause,cr,args); -% cr2name. Constructs a string for the cr of a component. +function crname = cr2name(name,RHS_number,LHS_cause,RHS_cause,cr,args,port); +% cr2name - Constructs a string for the cr of a component. +% % +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %%%%% Model Transformation Tools %%%%% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Matlab function cr2name +% cr2name(name,RHS_number,LHS_cause,RHS_cause,cr,args); + +% Copyright (c) P.J. Gawthrop, 1996. + % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ +% %% Revision 1.2 1996/08/22 18:31:06 peter +% %% Fixed comment bug. +% %% % %% Revision 1.1 1996/08/22 13:14:39 peter % %% Initial revision % %% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +if nargin<7 + port=0 +end; if length(args)==0 a_comma = ''; else @@ -26,17 +43,25 @@ else cause_name = cause2name(LHS_cause); lp = '('; rp = ')'; c_comma = ','; +end + +if port == 0 + port_name = ''; + p_comma = ''; +else + port_name = sprintf('%1.0f',port); + p_comma = ','; end; -name = sprintf('%s%s%s%s%s%s%s%s', ... - cr,lp, args, a_comma, cause_name, c_comma, ... - varname(RHS_number,RHS_cause),rp); +crname = sprintf('%s%s%s%s%s%s%s%s%s\t%s', ... + cr,lp, args, a_comma, port_name, p_comma, cause_name, c_comma, ... + varname(name, RHS_number,RHS_cause),rp); Index: mttroot/mtt/bin/trans/m/equation.m ================================================================== --- mttroot/mtt/bin/trans/m/equation.m +++ mttroot/mtt/bin/trans/m/equation.m @@ -15,10 +15,13 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ +% %% Revision 1.5 1996/12/05 11:26:51 peterg +% %% Null strings now detected with strcmp not length. +% %% % %% Revision 1.4 1996/09/12 16:42:01 peter % %% Default now out side this function - need to be none for each % %% component. % %% % %% Revision 1.3 1996/09/12 12:03:58 peter @@ -33,13 +36,15 @@ % %% Initial revision % %% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +inbonds +incauses % Find the number of inports -nports = length(inbonds); +nports = length(inbonds) % Check some arguments if length(incauses) ~= nports error('equation.m: incauses inconsistent with inbonds'); end; Index: mttroot/mtt/bin/trans/m/figfig.m ================================================================== --- mttroot/mtt/bin/trans/m/figfig.m +++ mttroot/mtt/bin/trans/m/figfig.m @@ -1,49 +1,41 @@ -function psfig(filename) - ## Usage: psfig(filename) - ## Puts figure into ps file +function figfig(filename,language) + ## Usage: figfig(filename[,language]) + ## Puts octave figure into fig file (filename.fig) + ## If second argument, converts to filename.language using fig2dev + ## eg: + ## figfig("foo"); + ## figfig("foo","eps"); + ## figfig("foo","pdf"); ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ - ## Revision 1.3 2000/10/09 14:41:47 peterg - ## Put back color - ## - ## Revision 1.2 2000/10/09 09:53:14 peterg - ## Changed font size - ## - ## Revision 1.1 1999/11/30 23:26:21 peterg - ## Initial revision - ## - ## Revision 1.3 1999/09/04 02:23:30 peterg - ## Removed mv stuff - now uses gset on actual file - ## - ## Revision 1.2 1999/06/15 02:05:44 peterg - ## Now adds a .ps if not there already - ## - ## Revision 1.1 1999/03/25 01:35:00 peterg - ## Initial revision - ## + ## Revision 1.1 2000/11/03 10:43:10 peterg + ## Initial revision ############################################################### - ## Add .ps if not there already - if !index(filename,".") # Is there a . - filename = sprintf("%s.ps",filename); - endif - - eval(sprintf("gset output \"%s\" ",filename)); - gset linestyle 1 lw 4 # Thicker lines - gset linestyle 2 lw 4 # Thicker lines - gset linestyle 3 lw 4 # Thicker lines - gset linestyle 4 lw 4 # Thicker lines - gset linestyle 5 lw 4 # Thicker lines - - - gset term postscript eps color 30 + figfilename = sprintf("%s.fig",filename); + + eval(sprintf("gset output \"%s\" ",figfilename)); + + gset term fig color portrait fontsize 16 size 20 10 metric replot; gset term x11 gset output replot; + ## Add a box - makes a visible bounding box + fid = fopen(figfilename,"a+"); + fprintf(fid,"2 4 0 2 31 7 50 0 -1 0.000 0 0 7 0 0 5\n"); + fprintf(fid,"\t9675 5310 9675 270 225 270 225 5310 9675 5310\n"); + fclose(fid); + + if nargin>1 # Do a ps file + psfilename = sprintf("%s.%s",filename,language); + convert = sprintf("fig2dev -L%s %s > %s", language, figfilename, psfilename) + system(convert); + endif + endfunction Index: mttroot/mtt/bin/trans/m/mtt_euler.m ================================================================== --- mttroot/mtt/bin/trans/m/mtt_euler.m +++ mttroot/mtt/bin/trans/m/mtt_euler.m @@ -1,6 +1,6 @@ -function [x] = mtt_euler(x,dx,dt,stepfactor,Nx,open) # Euler update +function [x] = mtt_euler(x,dx,dt,Nx,open) # Euler update I_open = nozeros(open.*[1:Nx]'); # Indices of open switches x(I_open) = 0.0; # Open switches have zero state I = nozeros(!open.*[1:Nx]'); # Indices of states to update x(I) = x(I) + dx(I)*dt; # Update states except open switches. endfunction; Index: mttroot/mtt/bin/trans/m/mtt_sfreq.m ================================================================== --- mttroot/mtt/bin/trans/m/mtt_sfreq.m +++ mttroot/mtt/bin/trans/m/mtt_sfreq.m @@ -1,7 +1,7 @@ -function [w,y,y_theta] = mtt_sfreq(system_name,theta,indices); - ## usage: [t,y,y_theta] = mtt_sfreq(system_name,theta); +function [w,y,y_theta] = mtt_sfreq(system_name,theta,free); + ## usage: [w,y,y_theta] = mtt_sfreq(system_name,theta,free); ## ## Frequency response with name system_name and parameter vector theta ## The order of components in theta is determined in system_numpar.txt: ## y_theta contains the corresponding sensitivity functions ## Assumes system generated by the sBG approach @@ -10,42 +10,52 @@ ## $Id$ ## Assumes SISO system global mtt_n_parameters mtt_parameters # Global "argc argv" + global mtt_w # Frequencies (if not specified in simpar file + N = length(theta); + eval(sprintf("[nx,ny,nu,nz,nyz] = %s_def;", system_name)); if nargin<3 - indices = ones(size(theta)); + free = 1; + endif + + y_theta = []; + + if length(free)==0 + free=1; # Make the loop happen once to get y and X endif - N = length(theta); - if N!=length(indices) - error(sprintf("The length (%i) of indices must be the same as that of theta (%i)",length(indices),N)); + [n,m] = size(free); + if m==1 + free = free'; endif - - eval(sprintf("%s_simpar;", system_name)); # Read the "simulation" parameters - w = logspace(mttwmin,mttwmax,mttwsteps)'; # Frequency range + + eval(sprintf("%s_simpar;", system_name)); # Read the "simulation" + # parameters + if exist("mttwmin") # Compute frequency range + w = logspace(mttwmin,mttwmax,mttwsteps)'; # Frequency range + else # use global mtt_w + w = mtt_w; + endif y_theta = []; - mtt_n_parameters = 2*N; - mtt_parameters(2:2:2*N) = theta; # The actual parameters - for i = 1:N - if indices(i) - mtt_parameters(1:2:2*N-1) = 0; # The sensitivity switches are off - mtt_parameters(2*i-1) = 1; # Set the approriate sensitivity switch - # on - eval(sprintf("%s_numpar;", system_name)); # Read the parameters - eval(sprintf("[A,B,C,D,E] = %s_dm;", system_name)); # Evaluate the descriptor matrices - fr = dm2fr(A,B,C,D,E,w); - y_theta = [y_theta fr(:,2)]; # Sensitivity frequency response - endif - + mtt_n_parameters = 1+N; + mtt_parameters(2:1+N) = theta; # The actual parameters + for i = free + mtt_parameters(1) = i; # Select wich sens. function + eval(sprintf("%s_numpar;", system_name)); # Read the parameters + eval(sprintf("[A,B,C,D,E] = %s_dm;", system_name)); # Evaluate the + # descriptor matrices + fr = dm2fr(A,B,C,D,E,w); + y_theta = [y_theta fr(:,2)]; # Sensitivity frequency response endfor y = fr(:,1); # Actual frequency response endfunction Index: mttroot/mtt/bin/trans/m/psfig.m ================================================================== --- mttroot/mtt/bin/trans/m/psfig.m +++ mttroot/mtt/bin/trans/m/psfig.m @@ -5,10 +5,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ + ## Revision 1.1 1999/11/30 23:26:21 peterg + ## Initial revision + ## ## Revision 1.3 1999/09/04 02:23:30 peterg ## Removed mv stuff - now uses gset on actual file ## ## Revision 1.2 1999/06/15 02:05:44 peterg ## Now adds a .ps if not there already @@ -21,13 +24,20 @@ ## Add .ps if not there already if !index(filename,".") # Is there a . filename = sprintf("%s.ps",filename); endif - gset term postscript eps eval(sprintf("gset output \"%s\" ",filename)); + gset linestyle 1 lw 4 # Thicker lines + gset linestyle 2 lw 4 # Thicker lines + gset linestyle 3 lw 4 # Thicker lines + gset linestyle 4 lw 4 # Thicker lines + gset linestyle 5 lw 4 # Thicker lines + + + gset term postscript eps replot; gset term x11 gset output replot; endfunction Index: mttroot/mtt/bin/trans/m/replace_name.m ================================================================== --- mttroot/mtt/bin/trans/m/replace_name.m +++ mttroot/mtt/bin/trans/m/replace_name.m @@ -4,13 +4,16 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.1 1998/07/02 12:36:39 peterg +## Initial revision +## ############################################################### - +string_array,new,index [N,M]=size(string_array); L = length(new); if index>N error(["String array has less than ", num2str(index), " rows"]); Index: mttroot/mtt/bin/trans/m/varname.m ================================================================== --- mttroot/mtt/bin/trans/m/varname.m +++ mttroot/mtt/bin/trans/m/varname.m @@ -13,11 +13,16 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ +% %% Revision 1.1 1996/08/27 08:08:44 peterg +% %% Initial revision +% %% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -bond_name = [name,'_bond']; +%bond_name = [name,'_bond']; +%name =sprintf('%s%1.0f_%s', bond_name, index, cause2name(causality)); -name =sprintf('%s%1.0f_%s', bond_name, index, cause2name(causality)); +bond_name = [name,'(']; +name =sprintf('%s(%1.0f,%1.0f)', name, index, cause2num(causality)); Index: mttroot/mtt/bin/trans/m/write_matrix.m ================================================================== --- mttroot/mtt/bin/trans/m/write_matrix.m +++ mttroot/mtt/bin/trans/m/write_matrix.m @@ -5,10 +5,13 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ +% %% Revision 1.5 1998/02/03 08:40:39 peterg +% %% Fixed a horrible bug -- changed filename -> filenum +% %% % %% Revision 1.4 1996/08/15 11:56:11 peter % %% Does complex matrices. % %% % %% Revision 1.3 1996/08/14 19:20:41 peter % %% Fixed output naming bug. @@ -33,15 +36,14 @@ fprintf(filenum, 'data = [\n'); [N,M] = size(matrix); for row = 1:N for col = 1:M - re = real(matrix(row,col)); - im = imag(matrix(row,col)); - fprintf(filenum, '%g', re); - if im ~= 0 - fprintf(filenum, '+ %g*i', im); + value = matrix(row,col); + fprintf(filenum, '%g', real(value)); + if is_complex(value) + fprintf(filenum, '+ %g*i', imag(value)); end if col