Index: mttroot/mtt/lib/control/PPP/ppp_indices.m ================================================================== --- mttroot/mtt/lib/control/PPP/ppp_indices.m +++ mttroot/mtt/lib/control/PPP/ppp_indices.m @@ -1,31 +1,48 @@ -function indices = ppp_indices (names,sympar) +function indices = ppp_indices (names,sympar,sympars) ## usage: indices = ppp_indices (names,sympar) ## ## names: column vector of component names - ## sympar: mtt-generated data structure od symbolic parameters + ## sympar symbolic parameter structure for system + ## sympars symbolic parameter structure for sensitivity system + + + ## Returns a matrix indices with 3 columns, one row per name + ## First col: index of ith parameter of sensitivity system + ## Second col: index of ith sensitivity parameter of sensitivity system + ## Third col : index of ith parameter of system + ## Copyright (C) 2002 by Peter J. Gawthrop - + ## Sanity check + if nargin<3 + printf("Usage: ppp_indices (names,sympar,sympars)\n"); + return + endif + ## Set up the indices = []; [n,m] = size(names); for i = 1:n p_name = deblank(names(i,:)); s_name = sprintf("%ss", p_name); - if struct_contains(sympar, p_name) - i_p = eval(sprintf("sympar.%s;", p_name)); - if struct_contains(sympar, s_name) - i_s = eval(sprintf("sympar.%s;", s_name)); - indices_i = eval(sprintf("[%i,%i];", i_p, i_s)); - indices = [indices; indices_i]; + if struct_contains(sympars, p_name) + i_ps = eval(sprintf("sympars.%s;", p_name)); + if struct_contains(sympars, s_name) + i_s = eval(sprintf("sympars.%s;", s_name)); + if struct_contains(sympar, p_name) + i_p = eval(sprintf("sympar.%s;", p_name)); + indices_i = eval(sprintf("[%i,%i,%i];", i_ps, i_s, i_p)); + indices = [indices; indices_i]; + else + printf("Parameter %s does not exist in sympar: ignoring\n", p_name) + endif else - printf("Sensitivity parameter %s does not exist: ignoring \ + printf("Sensitivity parameter %s does not exist in sympars: ignoring \ parameter %s\n", s_name, p_name); endif else - printf("Parameter %s does not exist: ignoring\n", p_name) + printf("Parameter %s does not exist in sympars: ignoring\n", p_name) endif endfor - endfunction Index: mttroot/mtt/lib/control/PPP/ppp_ippp.m ================================================================== --- mttroot/mtt/lib/control/PPP/ppp_ippp.m +++ mttroot/mtt/lib/control/PPP/ppp_ippp.m @@ -1,15 +1,15 @@ function i_ppp = ppp_ippp (n_ppp,sympar,sympars) ## usage: i_ppp = ppp_ippp (n_ppp,sympar,sympars) ## nppp number of ppp parameters - ## sympar symbolic parameter structure for system + ## sympars symbolic parameter structure for system ## sympar symbolic parameter structure for sensitivity system ## Returns a matrix i_ppp with n_ppp rows and 3 columns ## First col: index of ith ppp parameter of sensitivity system ## Second col: index of ith ppp sensitivity parameter of sensitivity system - ## Third col : index of ith ppp sensitivity parameter of system + ## Third col : index of ith ppp parameter of system ## Copyright (C) 2002 by Peter J. Gawthrop i_ppp = []; for i=1:n_ppp i_ppp_i = eval(sprintf("[sympars.ppp_%i, sympars.ppp_%is \