Index: mttroot/mtt/bin/trans/m/mtt_stime.m ================================================================== --- mttroot/mtt/bin/trans/m/mtt_stime.m +++ mttroot/mtt/bin/trans/m/mtt_stime.m @@ -1,7 +1,7 @@ -function [t,y,y_theta,x] = mtt_stime(system_name,theta,free); - ## usage: [t,y,y_theta] = mtt_stime(system_name,theta); +function [t,y,y_theta,x,x_last] = mtt_stime(system_name,theta,free); + ## usage: [t,y,y_theta,x,x_last] = mtt_stime(system_name,theta); ## ## Simulate system 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 @@ -34,24 +34,31 @@ for j=1:length(theta) args = sprintf("%s %g",args, theta(j)); endfor ## Run system and replace NaN by 1e30 -- easier to handle - command = sprintf("./%s_ode2odes.out %s | sed \'s/NAN/1e30/g\' >mtt_data.dat\n", \ - system_name, args); + file_name = sprintf("%s_input.dat", system_name); + if exist(file_name)==2 # Then use data from this file ... + command = sprintf("./%s_ode2odes.out %s < %s | sed \'s/NAN/Inf/g\' >mtt_out_data.dat\n", \ + system_name, args, file_name); + else + command = sprintf("./%s_ode2odes.out %s | sed \'s/NAN/Inf/g\' >mtt_out_data.dat\n", \ + system_name, args); + endif + system(command); - ## Retrieve data - load -force mtt_data.dat - y_theta = [y_theta mtt_data(:,3:2:1+ny)]; + ## Retrieve out_data + load -force mtt_out_data.dat + y_theta = [y_theta mtt_out_data(:,3:2:1+ny)]; endfor - ## System data - [n,m]=size(mtt_data); - t = mtt_data(:,1); - y = mtt_data(:,2:2:ny); - x = mtt_data(:,3+ny:m); - + ## System out_data + [n,m]=size(mtt_out_data); + t = mtt_out_data(:,1); + y = mtt_out_data(:,2:2:ny); + x = mtt_out_data(:,3+ny:m); + x_last = mtt_out_data(n,3+ny:m); endfunction