ADDED mttroot/mtt/bin/trans/m/add_bond.m Index: mttroot/mtt/bin/trans/m/add_bond.m ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/m/add_bond.m @@ -0,0 +1,36 @@ +function comp_list = add_bond(comp_list,bond_number,comp_number); + + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% Version control history +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% $Id$ +% %% $Log$ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% Adds a new bond entry to a list of components -- pads the list appropriately. + +[N,M] = size(comp_list); +if M==0 + M=1; +end; + +if comp_number>N % Pad with zeros + comp_list = [comp_list;zeros(comp_number-N,M)]; +end; + +this_comp = [nozeros(comp_list(comp_number,:)), bond_number]; + +L = length(this_comp); + +[N,M] = size(comp_list); + +if LM %pad matrix with zeros and insert new row + comp_list = [comp_list zeros(N,L-M)]; + comp_list(comp_number,:) = this_comp; +else %Sizes match so just insert + comp_list(comp_number,:) = this_comp; +end; ADDED mttroot/mtt/bin/trans/m/add_row.m Index: mttroot/mtt/bin/trans/m/add_row.m ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/m/add_row.m @@ -0,0 +1,16 @@ +function New=add_row(Old,Row); # Adds a row to end of matrix + + [N,M]=size(Old); + [n,m] = size(Row); + + if m>M + Old = [Old, zeros(N,m-M)]; # Pad with zeros + elseif M>m + Row = [Row, zeros(n,M-m)]; + endif + + New = [Old;Row]; + +endfunction + + ADDED mttroot/mtt/bin/trans/m/length2d.m Index: mttroot/mtt/bin/trans/m/length2d.m ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/m/length2d.m @@ -0,0 +1,24 @@ +function len = length2d(vector_array) +% length2d - Finds (geometric) length of row vectors stacked +% into a column vector +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %%%%% Model Transformation Tools %%%%% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Matlab function length2d +% len = length2d(vector_array) + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% Version control history +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% $Id$ +% %% $Log$ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% Copyright (c) P.J. Gawthrop, 1996. + +% + +len = sqrt(sum(vector_array'.^2)');