Index: mttroot/mtt/bin/trans/dm2fr_m ================================================================== --- mttroot/mtt/bin/trans/dm2fr_m +++ mttroot/mtt/bin/trans/dm2fr_m @@ -13,10 +13,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.15 2003/05/08 18:46:45 gawthrop +## Fixed range bug by using isfield in place of exists +## ## Revision 1.14 2000/05/20 15:35:18 peterg ## Parameterised version ## ## Revision 1.13 1998/09/03 09:12:32 peterg ## Removed debugging lines @@ -90,24 +93,24 @@ [nx,ny,nu,nz,nyz] = $1_def; %Defaults - if (struct_contains(simpar,"wmin")==0) + if (isfield(simpar,"wmin")==0) simpar.wmin = -1; end; - if (struct_contains(simpar,"wmax")==0) + if (isfield(simpar,"wmax")==0) simpar.wmax = 2 end; - if (struct_contains(simpar,"wsteps")==0) + if (isfield(simpar,"wsteps")==0) simpar.wsteps = 100; end; W = logspace(simpar.wmin,simpar.wmax,simpar.wsteps)'; - if (struct_contains(simpar,"mttinput")==0) + if (isfield(simpar,"mttinput")==0) mttinput = 1; end; mttu0 = zeros(nu,1); mttu0(mttinput) = 1; Index: mttroot/mtt/bin/trans/m/abg2cbg.m ================================================================== --- mttroot/mtt/bin/trans/m/abg2cbg.m +++ mttroot/mtt/bin/trans/m/abg2cbg.m @@ -18,10 +18,14 @@ ## ############################################################### ## ## Version control history ## ############################################################### ## ## $Id$ ## ## $Log$ + ## ## Revision 1.52 2004/09/07 18:22:53 geraint + ## ## Issues a more helpful error message than the cryptic Octave stuff + ## ## if there are unconnected ports. + ## ## ## ## Revision 1.51 2004/02/20 20:42:40 geraint ## ## Initialize Flipped.cons with [] instead of "". ## ## ## ## Revision 1.50 2003/03/13 15:18:39 gawthrop ## ## Now uses __ to delimit subsystems in names. @@ -258,18 +262,18 @@ end; ## Evaluate the system function to get the bonds and number of ports ##eval(["[bonds,components,n_ports,N_ports]=", fun_name, ";"]); eval(["[ABG]=", fun_name, ";"]); - !struct_contains(ABG,"subsystems") - if !struct_contains(ABG,"subsystems")# Are there any subsystems? + !isfield(ABG,"subsystems") + if !isfield(ABG,"subsystems")# Are there any subsystems? return; # Nothing to do else - [n_subsystems,junk] = size(struct_elements(ABG.subsystems)) + [n_subsystems,junk] = size(fieldnames(ABG.subsystems)) endif - if struct_contains(ABG,"portlist")# Are there any ports? + if isfield(ABG,"portlist")# Are there any ports? [n_ports,junk] = size(ABG.portlist); ## port_bond_index=zeros(n_ports,1); i_port = 0; for i=1:n_ports # Find indices of the internal ports name = deblank(ABG.portlist(i,:)); # Name of this port @@ -366,11 +370,11 @@ fields=["ports";"subsystems"]; # Do for both ports and subsystems - ## ports first for i=1:2 field=deblank(fields(i,:)); - if struct_contains(ABG,field); + if isfield(ABG,field); eval(["ABG_field = ABG.",field, ";"]); field,ABG_field sum_ok = 0; n_comp = 0; for [subsystem,name] = ABG_field# Find % status = 0 (causally complete) @@ -486,11 +490,11 @@ ABG.bonds(ci_bond_index,1:2) = prefered*ci_direction'*[1 1] eval(["ABG.subsystems.",name,".status=0"]); #set status of the C or I endif endwhile # ( ci_index>0) eval(["ABG.",field," = ABG_field;"]); # Copy back to actual structure - endif # struct_contains(CBG,field(i,:)); + endif # isfield(CBG,field(i,:)); endfor ## if n_ports>0 ## status(1:n_ports) = zeros(n_ports,1); # Port status not relevant ## endif; Index: mttroot/mtt/bin/trans/m/alias_args.m ================================================================== --- mttroot/mtt/bin/trans/m/alias_args.m +++ mttroot/mtt/bin/trans/m/alias_args.m @@ -3,10 +3,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.8 2001/06/13 16:07:15 gawthrop +## Fixed bug with three separators in a row eg )/( +## ## Revision 1.7 2001/06/13 14:50:15 gawthrop ## Operator ^ now ok in args in abg and/or lbl ## ## Revision 1.6 2001/04/23 16:23:30 gawthrop ## Now stips ; from bottlom level argument list - allows aliasing of @@ -30,18 +33,18 @@ ## Revision 1.1 1998/07/03 18:29:40 peterg ## Initial revision ## ############################################################### - if is_struct(alias) + if isstruct(alias) if !isempty(args) Args = split(args,delim); args=""; [N,M]= size(Args); for i=1:N arg = deblank(Args(i,:)); arg_ = strrep(arg,",","__"); - if struct_contains(alias,arg_) + if isfield(alias,arg_) eval(["new_arg = alias.", arg_,";"]); mtt_info(["Replacing ", arg, "\t by ",\ new_arg, message],FileID); mtt_save_alias(arg,sys_name); ## printf("%s --> %s\n",arg,new_arg); Index: mttroot/mtt/bin/trans/m/cbg2ese.m ================================================================== --- mttroot/mtt/bin/trans/m/cbg2ese.m +++ mttroot/mtt/bin/trans/m/cbg2ese.m @@ -21,10 +21,14 @@ ## ############################################################### ## ## Version control history ## ############################################################### ## ## $Id$ ## ## $Log$ + ## ## Revision 1.53 2005/03/21 11:09:47 gawthrop + ## ## Now handles bicausal SS component - + ## ## ie source-source or sensor-sensor + ## ## ## ## Revision 1.52 2004/09/12 22:27:27 geraint ## ## Appended 't' to fopen mode string to open in text mode. ## ## ## ## Revision 1.51 2003/05/16 11:16:28 gawthrop ## ## Fixed bug with multiports @@ -308,11 +312,11 @@ ## ports first lists=["portlist";"subsystemlist"]; for i=1:2 field=deblank(fields(i,:)); list=deblank(lists(i,:)); - if struct_contains(CBG,list); + if isfield(CBG,list); eval(["namelist=CBG.",list,";"]); # List of ports/subsystems [N,M]=size(namelist); # Number of ports/subsystems for j=1:N comp_name = deblank(namelist(j,:)); # Name of this component eval(["subsystem=CBG.",field,".",comp_name,";"]); # Pluck out the details @@ -325,19 +329,19 @@ ## disp(["---- ", field, " ---"]); if AliasingArguments # Alias the args list if appropriate message = sprintf("\tfor component %s (%s) within %s",\ comp_name,subsystem.type,full_name); - if struct_contains(CBG,"alias") + if isfield(CBG,"alias") subsystem.arg = alias_args(subsystem.arg,CBG.alias,";",message,infofilenum,full_name); endif; endif; if AliasingCRs # Alias the CR list if appropriate message = sprintf("\tfor component %s (%s) within %s",\ comp_name,subsystem.type,full_name); - if struct_contains(CBG,"alias") + if isfield(CBG,"alias") subsystem.cr = alias_args(subsystem.cr,CBG.alias,";",message,infofilenum,full_name); endif; endif; ## Substitute positional ($1 etc) arguments @@ -438,11 +442,11 @@ # ## Extract the unit/domain stuff # this_port_name = subABG.portlist(port_number,:); # eval(sprintf("this_port = subABG.ports.%s;", \ # this_port_name)); -# if struct_contains(this_port,"units") +# if isfield(this_port,"units") # eval(["effort_unit = \ # subABG.ports.",this_port_name,".units.effort;"]); # eval(["flow_unit = \ # subABG.ports.",this_port_name,".units.flow;"]); # else @@ -568,17 +572,17 @@ endif endfor fflush (structure_file); ## component interface definition - if struct_contains(CBG,"icd") - if struct_contains(CBG.icd,comp_name) + if isfield(CBG,"icd") + if isfield(CBG.icd,comp_name) if AliasingArguments subsystem.icd = alias_args(eval(["CBG.icd.",comp_name]),CBG.alias,";",message,infofilenum,full_name); endif endif - if (struct_contains(subsystem,"icd")) + if (isfield(subsystem,"icd")) subsystem.icd = subs_arg(subsystem.icd,system_args, ... "null",full_name,subsystem.type,comp_name,infofilenum); fprintf(icd_file,"%s_%s\t%s\t",full_name_repetition,comp_name,subsystem.icd); if (comp_bonds(1) == 1) @@ -593,15 +597,15 @@ endif endif endif # End of component interface definition endfor # [subsystem,comp_name] = CBG_field - endif # struct_contains(CBG,field) + endif # isfield(CBG,field) endfor # i=1:2 fclose(icd_file); fclose(ese_file); # Close endfunction Index: mttroot/mtt/bin/trans/m/cbg2fig.m ================================================================== --- mttroot/mtt/bin/trans/m/cbg2fig.m +++ mttroot/mtt/bin/trans/m/cbg2fig.m @@ -22,10 +22,13 @@ ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ## %% Version control history ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ## %% $Id$ ## %% $Log$ + ## %% Revision 1.17 2004/09/12 22:27:27 geraint + ## %% Appended 't' to fopen mode string to open in text mode. + ## %% ## %% Revision 1.16 2001/03/23 14:58:16 gawthrop ## %% Fixed cosmetic bugs -- component display ## %% ## %% Revision 1.15 2001/03/23 11:20:20 gawthrop ## %% Fixed bug with vector components --NB takes geometric info from _rbg.fig @@ -106,11 +109,11 @@ if nargin<9 comp_colour_o = 4; %Red end; ## Create a back slash '\' character. - bs = setstr(92); + bs = char(92); ## Create the (full) system name if strcmp(full_name,'') full_name = system_name; else @@ -152,11 +155,11 @@ [N_rports,junk] = size(port_list); [N_components, Columns] = size(CBG.subsystemlist); # Number of derived # components - if struct_contains(CBG,'portlist') + if isfield(CBG,'portlist') [N_ports, Columns] = size(CBG.portlist); else N_ports = 0; end Index: mttroot/mtt/bin/trans/m/ibg2abg.m ================================================================== --- mttroot/mtt/bin/trans/m/ibg2abg.m +++ mttroot/mtt/bin/trans/m/ibg2abg.m @@ -85,19 +85,19 @@ ## count number of vector bonds on each component ## #################################################### if (isfield(objects, "comp")) for [comp, comp_name] = objects.comp - n = size(struct_elements(comp))(1) - 1; + n = size(fieldnames(comp))(1) - 1; eval(sprintf("objects.comp.%s.n_bonds = %i;", comp_name, n)); endfor endif if (isfield(objects, "port")) for [port, port_name] = objects.port - n = size(struct_elements(port))(1) - 1; + n = size(fieldnames(port))(1) - 1; eval(sprintf("objects.port.%s.n_bonds = %i;", port_name, n)); endfor endif @@ -336,12 +336,12 @@ head_bond = eval(head_str); tail_bond = eval(tail_str); ## check compatible sizes - head.n_subs = size(struct_elements(head_bond))(1) - 2; - tail.n_subs = size(struct_elements(tail_bond))(1) - 2; + head.n_subs = size(fieldnames(head_bond))(1) - 2; + tail.n_subs = size(fieldnames(tail_bond))(1) - 2; if (head.n_subs != tail.n_subs) mtt_error(sprintf("Vector ports '%s' (%s:%s) and '%s' (%s:%s) are not compatible", head_bond.label, head.type, head_name, tail_bond.label, tail.type, tail_name), errorfile); @@ -415,18 +415,18 @@ ## map component data to cmp.m ## ################################# ## count number of components if (isfield(objects, "comp")) - n_comps = size(struct_elements(objects.comp), 1) + n_comps = size(fieldnames(objects.comp), 1) else n_comps = 0; endif ## count number of internal ports if (isfield(objects, "port")) - n_ports = size(struct_elements(objects.port), 1) + n_ports = size(fieldnames(objects.port), 1) else n_ports = 0; endif ## read data from _cmp.m @@ -481,11 +481,11 @@ ########################################### ## Write connections matrix (components) ## ########################################### if (isfield(objects, "comp")) - n_comps = size(struct_elements(objects.comp))(1); + n_comps = size(fieldnames(objects.comp))(1); else n_comps = 0; endif components = zeros(n_comps+n_ports, max(n_vector_bonds)); Index: mttroot/mtt/bin/trans/m/mtt_alias.m ================================================================== --- mttroot/mtt/bin/trans/m/mtt_alias.m +++ mttroot/mtt/bin/trans/m/mtt_alias.m @@ -26,11 +26,11 @@ endif ## Argument aliasing message = sprintf("\tfor component %s within %s",name,Name); - if struct_contains(cbg,"alias") + if isfield(cbg,"alias") args = alias_args(args,cbg.alias,";",message,filenum,fullname); endif; ## Substitute positional params Args = eval(sprintf("Cbg.subsystems.%s.arg;", name)); Index: mttroot/mtt/bin/trans/m/mtt_component_eqn.m ================================================================== --- mttroot/mtt/bin/trans/m/mtt_component_eqn.m +++ mttroot/mtt/bin/trans/m/mtt_component_eqn.m @@ -40,11 +40,11 @@ known = " "; endif if length(Name)>0 cbg = mtt_cbg(Name); # Structure for this subsystem - if struct_contains (cbg, "ports") + if isfield (cbg, "ports") ## Combine ports with the other subsystems for [component_structure, component] = cbg.ports eval(sprintf("cbg.subsystems.%s=cbg.ports.%s;",component,component)); endfor endif @@ -59,11 +59,11 @@ ## Alias CRs eval(sprintf("CR=cbg.subsystems.%s.cr;", name)); # CRs CR = mtt_alias (Name,CR,cr_default); # Alias them eval(sprintf("cbg.subsystems.%s.cr=CR;", name)); # and copy else # Call to a subsystem (represented by name="") - if !struct_contains(cbg,"portlist") + if !isfield(cbg,"portlist") N_ports = 0; else [N_ports,M_ports] = size(cbg.portlist); endif @@ -163,12 +163,12 @@ innames endif ## Is the signal the output of a port? is_port_output = 0; # Default - if struct_contains (cbg, "ports") - if struct_contains (cbg.ports,name) + if isfield (cbg, "ports") + if isfield (cbg.ports,name) is_port_output = (outsig(2)!=insigs(1,2)); endif endif if is_port_output Index: mttroot/mtt/bin/trans/m/rbg2abg.m ================================================================== --- mttroot/mtt/bin/trans/m/rbg2abg.m +++ mttroot/mtt/bin/trans/m/rbg2abg.m @@ -5,10 +5,13 @@ ## ############################################################### ## ## Version control history ## ############################################################### ## ## $Id$ ## ## $Log$ + ## ## Revision 1.49 2004/07/22 13:18:02 geraint + ## ## Minor typo in error message. + ## ## ## ## Revision 1.48 2004/02/19 18:27:47 geraint ## ## [ 852694 ] octave 2.1.52 breaks rbg2abg ## ## ## ## Octave now prefers row vectors to column vectors. ## ## @@ -377,12 +380,12 @@ endif ## Replace by alias -- if any eval( ["alias = ", comp_type, '_alias';]); # Get aliases - if is_struct(alias) # are there any aliases - if struct_contains(alias,port_name_i) # Is this an alias? + if isstruct(alias) # are there any aliases + if isfield(alias,port_name_i) # Is this an alias? eval(["new_port_name_i = alias.",port_name_i]); mtt_info(["Aliasing name [" port_name_i "]\t on component " \ comp_name " (" comp_type ")\t to [" new_port_name_i "]"],infofile); port_name = replace_name(port_name, \ ["[",new_port_name_i,"]"], \ @@ -569,11 +572,11 @@ direction = sign(signed_bond_list); ##Find the port list for this component if exist([comp_type, '_cause'])==0 eval(["ABG = ",comp_type, "_abg;"]); - if struct_contains (ABG, "portlist") + if isfield (ABG, "portlist") port_list = ABG.portlist; else error(sprintf("Component %s has no ports", comp_type)); port_list = []; endif Index: mttroot/mtt/bin/trans/m/str2ch.m ================================================================== --- mttroot/mtt/bin/trans/m/str2ch.m +++ mttroot/mtt/bin/trans/m/str2ch.m @@ -13,19 +13,22 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ +% %% Revision 1.3 1996/12/04 21:39:55 peterg +% %% Changed to handle null string (octave returns lenghth of 1) +% %% % %% Revision 1.1 1996/08/30 09:54:44 peter % %% Initial revision % %% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% implicit_str_to_num_ok = 1; astr = abs(str); if (n>0) & (n<=length(str)) & (strcmp(str,'')==0) - ch = setstr(astr(n)); + ch = char(astr(n)); else ch = ''; end; Index: mttroot/mtt/bin/trans/m/write_abg.m ================================================================== --- mttroot/mtt/bin/trans/m/write_abg.m +++ mttroot/mtt/bin/trans/m/write_abg.m @@ -3,10 +3,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.11 2004/09/12 22:27:27 geraint +## Appended 't' to fopen mode string to open in text mode. +## ## Revision 1.10 2004/08/09 14:47:28 gawthrop ## Changed arg to args to avoid strange octave bug ## ## Revision 1.9 2001/04/15 21:15:41 geraint ## Added interface definition rep: _ICD.(txt|c|cc|m). @@ -175,23 +178,23 @@ fprintf(fid," ];\n"); fprintf(fid,"\n# Aliases \n"); fprintf(fid,"# A double underscore __ represents a comma \n"); eval(["alias = ", system_name, "_alias;"]); - if is_struct(alias) + if isstruct(alias) for [val,key] = alias fprintf(fid,"%s.alias.%s = \"%s\";\n", system_name,key,val); endfor endif fprintf(fid,"\n# Interface Definition\n"); eval(["icd = ",system_name, "_icd;"]); - if is_struct(icd) + if isstruct(icd) for [val,key] = icd fprintf(fid,"%s.icd.%s = \"%s\";\n",system_name,key,val); endfor endif fclose(fid); Index: mttroot/mtt/bin/trans/m/write_cbg.m ================================================================== --- mttroot/mtt/bin/trans/m/write_cbg.m +++ mttroot/mtt/bin/trans/m/write_cbg.m @@ -3,10 +3,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.5 2004/09/12 22:27:27 geraint +## Appended 't' to fopen mode string to open in text mode. +## ## Revision 1.4 1998/08/26 12:26:17 peterg ## Replaced if N>0 by if (N>0)&&(M>0) # Flipped ports exist ## ## Revision 1.3 1998/08/25 20:05:33 peterg ## Write flipped port info @@ -34,16 +37,16 @@ fprintf(fid,"\n# Acausal bond graph structure\n"); fprintf(fid," [%s] = %s_abg;\n", system_name, system_type); fprintf(fid,"\n# Status information\n"); -# if struct_contains(system,"ports") +# if isfield(system,"ports") # for [port,name]=system.ports # fprintf(fid,StatusFormat,system_name,"ports",name,port.status); # endfor; # endif - if struct_contains(system,"subsystems") + if isfield(system,"subsystems") for [subsystem,name]=system.subsystems fprintf(fid,StatusFormat,system_name,"subsystems",name,subsystem.status); endfor; endif Index: mttroot/mtt/bin/trans/m/write_ibg.m ================================================================== --- mttroot/mtt/bin/trans/m/write_ibg.m +++ mttroot/mtt/bin/trans/m/write_ibg.m @@ -1,11 +1,11 @@ ## -*-octave-*- function write_ibg(system_name,bonds); fid = fopen([system_name,"_ibg.m"], "wt"); - [nbonds, junk] = size(struct_elements(bonds)); + [nbonds, junk] = size(fieldnames(bonds)); format_hc = " %s.bonds.bond%i.head.component\t= \"%s\";\n"; format_tc = " %s.bonds.bond%i.tail.component\t= \"%s\";\n"; format_hp = " %s.bonds.bond%i.head.ports\t= \"%s\";\n"; format_tp = " %s.bonds.bond%i.tail.ports\t= \"%s\";\n"; format_ce = " %s.bonds.bond%i.causality.effort\t= \"%s\";\n"; 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.9 2006/09/27 13:55:08 geraint +% %% Write complex numbers in polar form instead of real and imaginary parts. +% %% % %% Revision 1.8 2004/09/12 22:27:27 geraint % %% Appended 't' to fopen mode string to open in text mode. % %% % %% Revision 1.7 2002/05/15 16:37:30 gawthrop % %% Added third argument (file extension) @@ -50,11 +53,11 @@ [N,M] = size(matrix); for row = 1:N for col = 1:M value = matrix(row,col); - if is_complex(value) + if iscomplex(value) fprintf(filenum, '%g*e^(%g*i)', abs(value),angle(value)); else fprintf(filenum, '%g', value); end if col