Comment: | Replaced deprecated functions from Octave 2.1 for Octave 3.0: is_struct -> isstruct, struct_contains -> isfield, struct_elements -> fieldnames, is_complex -> iscomplex, setstr -> char |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | origin/master | trunk |
Files: | files | file ages | folders |
SHA3-256: |
cce4dc617c2b000c09ef64479b02fffb |
User & Date: | geraint@users.sourceforge.net on 2009-11-02 16:54:03 |
Other Links: | branch diff | manifest | tags |
2012-10-15
| ||
19:17:19 | split is obsolete in Octave, replaced with strsplit and strtok. Semi-colons removed during debugging for more verbose log file. check-in: 078d645a0b user: geraint@users.sourceforge.net tags: origin/master, trunk | |
2009-11-02
| ||
16:54:03 | Replaced deprecated functions from Octave 2.1 for Octave 3.0: is_struct -> isstruct, struct_contains -> isfield, struct_elements -> fieldnames, is_complex -> iscomplex, setstr -> char check-in: cce4dc617c user: geraint@users.sourceforge.net tags: origin/master, trunk | |
16:51:54 | Recognises MTTz, but mttdz is yet to be handled in output equations check-in: 31ea8af321 user: geraint@users.sourceforge.net tags: origin/master, trunk | |
Modified mttroot/mtt/bin/trans/dm2fr_m from [302b8e2528] to [905d7cb644].
︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # Copyright (c) P.J.Gawthrop, 1996. ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## 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 ## ## Revision 1.12 1998/09/02 12:02:14 peterg | > > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # Copyright (c) P.J.Gawthrop, 1996. ############################################################### ## 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 ## ## Revision 1.12 1998/09/02 12:02:14 peterg |
︙ | ︙ | |||
88 89 90 91 92 93 94 | # Simulation parameters simpar=$1_simpar; [nx,ny,nu,nz,nyz] = $1_def; %Defaults | | | | | | 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 | # Simulation parameters simpar=$1_simpar; [nx,ny,nu,nz,nyz] = $1_def; %Defaults if (isfield(simpar,"wmin")==0) simpar.wmin = -1; end; if (isfield(simpar,"wmax")==0) simpar.wmax = 2 end; if (isfield(simpar,"wsteps")==0) simpar.wsteps = 100; end; W = logspace(simpar.wmin,simpar.wmax,simpar.wsteps)'; if (isfield(simpar,"mttinput")==0) mttinput = 1; end; mttu0 = zeros(nu,1); mttu0(mttinput) = 1; [n,m]=size(W); if m>n |
︙ | ︙ |
Modified mttroot/mtt/bin/trans/m/abg2cbg.m from [b9b1f81aae] to [d576ebb7c3].
︙ | ︙ | |||
16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ## [bonds,status] = abg2cbg(system_name, system_type, full_name, port_bonds, infofile) ## ############################################################### ## ## Version control history ## ############################################################### ## ## $Id$ ## ## $Log$ ## ## 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. ## ## ## ## Revision 1.49 2001/07/26 05:02:53 geraint | > > > > | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ## [bonds,status] = abg2cbg(system_name, system_type, full_name, port_bonds, infofile) ## ############################################################### ## ## 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. ## ## ## ## Revision 1.49 2001/07/26 05:02:53 geraint |
︙ | ︙ | |||
256 257 258 259 260 261 262 | status = []; return 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, ";"]); | | | | | | 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | status = []; return 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, ";"]); !isfield(ABG,"subsystems") if !isfield(ABG,"subsystems")# Are there any subsystems? return; # Nothing to do else [n_subsystems,junk] = size(fieldnames(ABG.subsystems)) endif 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 eval(["port = ABG.ports.",name,";"]); # Extract port info for j=1:length(port.connections) # Maybe vector SS |
︙ | ︙ | |||
364 365 366 367 368 369 370 | total = 2*n_bonds; done = sum(sum(abs(ABG.bonds)))/total*100; fields=["ports";"subsystems"]; # Do for both ports and subsystems - ## ports first for i=1:2 field=deblank(fields(i,:)); | | | 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | total = 2*n_bonds; done = sum(sum(abs(ABG.bonds)))/total*100; fields=["ports";"subsystems"]; # Do for both ports and subsystems - ## ports first for i=1:2 field=deblank(fields(i,:)); 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) eval(["ok = (ABG_field.",name,".status==0);"]); sum_ok = sum_ok + ok; n_comp ++; |
︙ | ︙ | |||
484 485 486 487 488 489 490 | prefered = -prefered; end; 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 | | | 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | prefered = -prefered; end; 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 # isfield(CBG,field(i,:)); endfor ## if n_ports>0 ## status(1:n_ports) = zeros(n_ports,1); # Port status not relevant ## endif; ## Print final causality ## final_done = (sum(status==zeros(n_components,1))/n_components)*100; |
︙ | ︙ |
Modified mttroot/mtt/bin/trans/m/alias_args.m from [33aaf8ec7f] to [c2ced77624].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | function args = alias_args(args,alias,delim,message,FileID,sys_name) ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## 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 ## parts of a,b,c (eg a,b by using a,b;c ## | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function args = alias_args(args,alias,delim,message,FileID,sys_name) ############################################################### ## 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 ## parts of a,b,c (eg a,b by using a,b;c ## |
︙ | ︙ | |||
28 29 30 31 32 33 34 | ## This makes it substitute for bits of args separated by commas. ## ## Revision 1.1 1998/07/03 18:29:40 peterg ## Initial revision ## ############################################################### | | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | ## This makes it substitute for bits of args separated by commas. ## ## Revision 1.1 1998/07/03 18:29:40 peterg ## Initial revision ## ############################################################### 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 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); arg = new_arg; ## else |
︙ | ︙ |
Modified mttroot/mtt/bin/trans/m/cbg2ese.m from [855720c30a] to [ea5247f84f].
︙ | ︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ## Structure matrix [states,nonstates,inputs,outputs,zero_outputs] ## ############################################################### ## ## Version control history ## ############################################################### ## ## $Id$ ## ## $Log$ ## ## 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 ## ## ## ## Revision 1.50 2003/05/08 18:47:50 gawthrop | > > > > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ## Structure matrix [states,nonstates,inputs,outputs,zero_outputs] ## ############################################################### ## ## 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 ## ## ## ## Revision 1.50 2003/05/08 18:47:50 gawthrop |
︙ | ︙ | |||
306 307 308 309 310 311 312 | fields=["ports";"subsystems"]; # Do for both ports and subsystems - ## ports first lists=["portlist";"subsystemlist"]; for i=1:2 field=deblank(fields(i,:)); list=deblank(lists(i,:)); | | | | | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | fields=["ports";"subsystems"]; # Do for both ports and subsystems - ## ports first lists=["portlist";"subsystemlist"]; for i=1:2 field=deblank(fields(i,:)); list=deblank(lists(i,:)); 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 comp = subsystem.connections; # Connections bond_list = abs(comp); direction = sign(comp)'*[1 1]; # Convert from arrow orientated to component orientated causality comp_bonds = CBG.bonds(bond_list,:).*direction; ## 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 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 isfield(CBG,"alias") subsystem.cr = alias_args(subsystem.cr,CBG.alias,";",message,infofilenum,full_name); endif; endif; ## Substitute positional ($1 etc) arguments subsystem.cr = subs_arg(subsystem.cr,system_cr, ... "lin",full_name,subsystem.type,comp_name,infofilenum); |
︙ | ︙ | |||
436 437 438 439 440 441 442 | # deblank(bond_flow_unit(port_bond_number,:)); # ## Extract the unit/domain stuff # this_port_name = subABG.portlist(port_number,:); # eval(sprintf("this_port = subABG.ports.%s;", \ # this_port_name)); | | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | # deblank(bond_flow_unit(port_bond_number,:)); # ## Extract the unit/domain stuff # this_port_name = subABG.portlist(port_number,:); # eval(sprintf("this_port = subABG.ports.%s;", \ # this_port_name)); # 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 # effort_unit = "none"; # flow_unit = "none"; |
︙ | ︙ | |||
566 567 568 569 570 571 572 | endfor; endif; endif endfor fflush (structure_file); ## component interface definition | | | | | | 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | endfor; endif; endif endfor fflush (structure_file); ## component interface definition 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 (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) fprintf(icd_file,"output,"); elseif (comp_bonds(1) == -1) fprintf(icd_file,"input,"); endif if (comp_bonds(2) == 1) fprintf(icd_file,"input\n"); elseif (comp_bonds(2) == -1) fprintf(icd_file,"output\n"); endif endif endif # End of component interface definition endfor # [subsystem,comp_name] = CBG_field endif # isfield(CBG,field) endfor # i=1:2 fclose(icd_file); fclose(ese_file); # Close endfunction |
Modified mttroot/mtt/bin/trans/m/cbg2fig.m from [7902a61185] to [7c46356009].
︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ## Copyright (c) P.J.Gawthrop, 1996. ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ## %% Version control history ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ## %% $Id$ ## %% $Log$ ## %% 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 ## %% ## %% Revision 1.14 2000/09/14 12:07:15 peterg | > > > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ## Copyright (c) P.J.Gawthrop, 1996. ## %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ## %% 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 ## %% ## %% Revision 1.14 2000/09/14 12:07:15 peterg |
︙ | ︙ | |||
104 105 106 107 108 109 110 | end; if nargin<9 comp_colour_o = 4; %Red end; ## Create a back slash '\' character. | | | 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | end; if nargin<9 comp_colour_o = 4; %Red end; ## Create a back slash '\' character. bs = char(92); ## Create the (full) system name if strcmp(full_name,'') full_name = system_name; else full_name = [full_name, '_', system_name]; end; |
︙ | ︙ | |||
150 151 152 153 154 155 156 | M_components = Columns; N_rcomponents = Rows; # Number of raw components [N_rports,junk] = size(port_list); [N_components, Columns] = size(CBG.subsystemlist); # Number of derived # components | | | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | M_components = Columns; N_rcomponents = Rows; # Number of raw components [N_rports,junk] = size(port_list); [N_components, Columns] = size(CBG.subsystemlist); # Number of derived # components if isfield(CBG,'portlist') [N_ports, Columns] = size(CBG.portlist); else N_ports = 0; end ## Rotation matrix |
︙ | ︙ |
Modified mttroot/mtt/bin/trans/m/ibg2abg.m from [5d61fecdc4] to [c68472150c].
︙ | ︙ | |||
83 84 85 86 87 88 89 | #################################################### ## count number of vector bonds on each component ## #################################################### if (isfield(objects, "comp")) for [comp, comp_name] = objects.comp | | | | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | #################################################### ## count number of vector bonds on each component ## #################################################### if (isfield(objects, "comp")) for [comp, comp_name] = objects.comp 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(fieldnames(port))(1) - 1; eval(sprintf("objects.port.%s.n_bonds = %i;", port_name, n)); endfor endif disp("-- finished counting number of bonds on components --") objects |
︙ | ︙ | |||
334 335 336 337 338 339 340 | tail_str = sprintf("objects.%s.%s.bond%i", tail_comp_or_port, tail_name, i) head_bond = eval(head_str); tail_bond = eval(tail_str); ## check compatible sizes | | | | 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | tail_str = sprintf("objects.%s.%s.bond%i", tail_comp_or_port, tail_name, i) head_bond = eval(head_str); tail_bond = eval(tail_str); ## check compatible sizes 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); elseif (head.n_subs > 1) mtt_info(sprintf("Vector port '%s'(%s:%s) matches '%s' (%s:%s)", |
︙ | ︙ | |||
413 414 415 416 417 418 419 | ################################# ## map component data to cmp.m ## ################################# ## count number of components if (isfield(objects, "comp")) | | | | 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | ################################# ## map component data to cmp.m ## ################################# ## count number of components if (isfield(objects, "comp")) n_comps = size(fieldnames(objects.comp), 1) else n_comps = 0; endif ## count number of internal ports if (isfield(objects, "port")) n_ports = size(fieldnames(objects.port), 1) else n_ports = 0; endif ## read data from _cmp.m for cmp = 1:(n_comps + n_ports) [this_type, this_name] = eval(sprintf("%s_cmp(%i)", name, cmp)); |
︙ | ︙ | |||
479 480 481 482 483 484 485 | n_vector_bonds ########################################### ## Write connections matrix (components) ## ########################################### if (isfield(objects, "comp")) | | | 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | n_vector_bonds ########################################### ## Write connections matrix (components) ## ########################################### if (isfield(objects, "comp")) n_comps = size(fieldnames(objects.comp))(1); else n_comps = 0; endif components = zeros(n_comps+n_ports, max(n_vector_bonds)); if (isfield(objects, "comp")) |
︙ | ︙ |
Modified mttroot/mtt/bin/trans/m/mtt_alias.m from [750fa34e3e] to [8f9f502367].
︙ | ︙ | |||
24 25 26 27 28 29 30 | else Cbg = mtt_cbg(Name); # Structure for this subsystem endif ## Argument aliasing message = sprintf("\tfor component %s within %s",name,Name); | | | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | else Cbg = mtt_cbg(Name); # Structure for this subsystem endif ## Argument aliasing message = sprintf("\tfor component %s within %s",name,Name); 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)); args = subs_arg(args,Args,default,Name,"",name,filenum); |
︙ | ︙ |
Modified mttroot/mtt/bin/trans/m/mtt_component_eqn.m from [78fbb4594b] to [50cfed29c8].
︙ | ︙ | |||
38 39 40 41 42 43 44 | if length(known)<2 # Invalid known = " "; endif if length(Name)>0 cbg = mtt_cbg(Name); # Structure for this subsystem | | | | 38 39 40 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 | if length(known)<2 # Invalid known = " "; endif if length(Name)>0 cbg = mtt_cbg(Name); # Structure for this subsystem 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 endif if length(name)>0 # Alias ##Alias arguments eval(sprintf("ARG=cbg.subsystems.%s.arg;", name)); # Arguments ARG = mtt_alias (Name,ARG,arg_default); # Alias them eval(sprintf("cbg.subsystems.%s.arg=ARG;", name)); # and copy ## 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 !isfield(cbg,"portlist") N_ports = 0; else [N_ports,M_ports] = size(cbg.portlist); endif if port>N_ports error(sprintf("port (%i) > N_ports (%i)", port, N_ports)); |
︙ | ︙ | |||
161 162 163 164 165 166 167 | outsig insigs innames endif ## Is the signal the output of a port? is_port_output = 0; # Default | | | | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | outsig insigs innames endif ## Is the signal the output of a port? is_port_output = 0; # Default if isfield (cbg, "ports") if isfield (cbg.ports,name) is_port_output = (outsig(2)!=insigs(1,2)); endif endif if is_port_output ## Which port (number) is it? [N_ports,M_ports] = size(cbg.portlist); |
︙ | ︙ |
Modified mttroot/mtt/bin/trans/m/rbg2abg.m from [88812e8fad] to [80cfe69023].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | function [bonds,components,n_vector_bonds] = rbg2abg(name,rbonds,rstrokes,rcomponents,\ port_coord,port_name,\ infofile,errorfile) ## ############################################################### ## ## Version control history ## ############################################################### ## ## $Id$ ## ## $Log$ ## ## 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. ## ## ## ## Revision 1.47 2002/08/27 16:09:01 geraint ## ## Added port_name to error message when multiple bonds are near a port. | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | function [bonds,components,n_vector_bonds] = rbg2abg(name,rbonds,rstrokes,rcomponents,\ port_coord,port_name,\ infofile,errorfile) ## ############################################################### ## ## 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. ## ## ## ## Revision 1.47 2002/08/27 16:09:01 geraint ## ## Added port_name to error message when multiple bonds are near a port. |
︙ | ︙ | |||
375 376 377 378 379 380 381 | ## port_name_i = deblank(port_name(port_name_index,:)); ## port_name_i = port_name_i(2:length(port_name_i)-1) # strip [] endif ## Replace by alias -- if any eval( ["alias = ", comp_type, '_alias';]); # Get aliases | | | | 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | ## port_name_i = deblank(port_name(port_name_index,:)); ## port_name_i = port_name_i(2:length(port_name_i)-1) # strip [] endif ## Replace by alias -- if any eval( ["alias = ", comp_type, '_alias';]); # Get aliases 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,"]"], \ port_name_index); endif |
︙ | ︙ | |||
567 568 569 570 571 572 573 | signed_bond_list = nozeros(components(i,:)); n_comp_bonds = length(signed_bond_list); direction = sign(signed_bond_list); ##Find the port list for this component if exist([comp_type, '_cause'])==0 eval(["ABG = ",comp_type, "_abg;"]); | | | 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | signed_bond_list = nozeros(components(i,:)); n_comp_bonds = length(signed_bond_list); direction = sign(signed_bond_list); ##Find the port list for this component if exist([comp_type, '_cause'])==0 eval(["ABG = ",comp_type, "_abg;"]); if isfield (ABG, "portlist") port_list = ABG.portlist; else error(sprintf("Component %s has no ports", comp_type)); port_list = []; endif else port_list=comp_ports(comp_type,n_comp_bonds) |
︙ | ︙ |
Modified mttroot/mtt/bin/trans/m/str2ch.m from [367266a7c0] to [6886463212].
︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ % %% 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) | > > > | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% 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 = char(astr(n)); else ch = ''; end; |
︙ | ︙ |
Modified mttroot/mtt/bin/trans/m/write_abg.m from [ec868dcca7] to [1dcbed067b].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | function write_abg(system_name,bonds,connections,n_vector_bonds); ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## 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). ## ## Revision 1.8 1999/10/18 22:41:41 peterg | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function write_abg(system_name,bonds,connections,n_vector_bonds); ############################################################### ## 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). ## ## Revision 1.8 1999/10/18 22:41:41 peterg |
︙ | ︙ | |||
173 174 175 176 177 178 179 | fprintf(fid,"\n"); endfor; fprintf(fid," ];\n"); fprintf(fid,"\n# Aliases \n"); fprintf(fid,"# A double underscore __ represents a comma \n"); eval(["alias = ", system_name, "_alias;"]); | | | | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | fprintf(fid,"\n"); endfor; fprintf(fid," ];\n"); fprintf(fid,"\n# Aliases \n"); fprintf(fid,"# A double underscore __ represents a comma \n"); eval(["alias = ", system_name, "_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 isstruct(icd) for [val,key] = icd fprintf(fid,"%s.icd.%s = \"%s\";\n",system_name,key,val); endfor endif fclose(fid); |
Modified mttroot/mtt/bin/trans/m/write_cbg.m from [bf1b05ce91] to [cabf88aa9f].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | function write_cbg(system_name,system_type,system,Flipped) ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## 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 ## ## Revision 1.2 1998/08/25 06:21:19 peterg | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function write_cbg(system_name,system_type,system,Flipped) ############################################################### ## 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 ## ## Revision 1.2 1998/08/25 06:21:19 peterg |
︙ | ︙ | |||
32 33 34 35 36 37 38 | fprintf(fid,"# Generated by MTT on %s",ctime(time)); fprintf(fid,"# The file is in Octave format\n"); fprintf(fid,"\n# Acausal bond graph structure\n"); fprintf(fid," [%s] = %s_abg;\n", system_name, system_type); fprintf(fid,"\n# Status information\n"); | | | | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | fprintf(fid,"# Generated by MTT on %s",ctime(time)); fprintf(fid,"# The file is in Octave format\n"); 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 isfield(system,"ports") # for [port,name]=system.ports # fprintf(fid,StatusFormat,system_name,"ports",name,port.status); # endfor; # endif if isfield(system,"subsystems") for [subsystem,name]=system.subsystems fprintf(fid,StatusFormat,system_name,"subsystems",name,subsystem.status); endfor; endif [N,M]=size(system.bonds); # Bonds fprintf(fid,"\n# Causal bond information\n"); |
︙ | ︙ |
Modified mttroot/mtt/bin/trans/m/write_ibg.m from [041b691f80] to [3ea7c08bfd].
1 2 3 4 5 | ## -*-octave-*- function write_ibg(system_name,bonds); fid = fopen([system_name,"_ibg.m"], "wt"); | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | ## -*-octave-*- function write_ibg(system_name,bonds); fid = fopen([system_name,"_ibg.m"], "wt"); [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"; format_cf = " %s.bonds.bond%i.causality.flow\t= \"%s\";\n"; |
︙ | ︙ |
Modified mttroot/mtt/bin/trans/m/write_matrix.m from [16a127a42d] to [80adc0845c].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | function write_matrix(matrix,name,extn); % Writes the matrix function file % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% Version control history % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% $Id$ % %% $Log$ % %% 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) % %% % %% Revision 1.6 2000/12/27 16:06:17 peterg | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | function write_matrix(matrix,name,extn); % Writes the matrix function file % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % %% 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) % %% % %% Revision 1.6 2000/12/27 16:06:17 peterg |
︙ | ︙ | |||
48 49 50 51 52 53 54 | fprintf(filenum, 'data = [\n'); [N,M] = size(matrix); for row = 1:N for col = 1:M value = matrix(row,col); | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | fprintf(filenum, 'data = [\n'); [N,M] = size(matrix); for row = 1:N for col = 1:M value = matrix(row,col); if iscomplex(value) fprintf(filenum, '%g*e^(%g*i)', abs(value),angle(value)); else fprintf(filenum, '%g', value); end if col<M fprintf(filenum, '\t'); end |
︙ | ︙ |
Modified mttroot/mtt/bin/trans/octave_ode2odes from [9934b36f54] to [abe17462de].
︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # Copyright (c) P.J.Gawthrop 1999 ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## Revision 1.5 2002/05/07 10:13:48 gawthrop ## Files marked by update as out of sync ## ## Revision 1.4 2001/03/30 15:13:58 gawthrop ## Rationalised simulation modes to each return mtt_data ## ## Revision 1.3 2000/05/19 17:47:56 peterg | > > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # Copyright (c) P.J.Gawthrop 1999 ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## Revision 1.6 2005/04/26 22:52:26 geraint ## The Octave load/save -ascii option is deprecated in favour of -text ## ## Revision 1.5 2002/05/07 10:13:48 gawthrop ## Files marked by update as out of sync ## ## Revision 1.4 2001/03/30 15:13:58 gawthrop ## Rationalised simulation modes to each return mtt_data ## ## Revision 1.3 2000/05/19 17:47:56 peterg |
︙ | ︙ | |||
34 35 36 37 38 39 40 | echo Creating $1_odes.dat2 $MATRIX <<EOF >octave_ode2odes.log 2>mtt_error.txt ## Set up the simulation parameters par = $1_numpar; x_0 = $1_state(par); simpar = $1_simpar mtt_data = $1_ode2odes(x_0,par,simpar); | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | echo Creating $1_odes.dat2 $MATRIX <<EOF >octave_ode2odes.log 2>mtt_error.txt ## Set up the simulation parameters par = $1_numpar; x_0 = $1_state(par); simpar = $1_simpar mtt_data = $1_ode2odes(x_0,par,simpar); if iscomplex(mtt_data) mtt_error("octave_ode2odes: Simulated data is complex - something is wrong!"); mtt_data = real(mtt_data); endif; save -text $1_odes.dat2 mtt_data EOF mtt_error mtt_error.txt |