GETOUTPUTCOUNTS - determine how many copies of each state variable and monitor will be produced by simulating the model. Usage: [state_var_counts,monitor_counts]=dsGetOutputCounts(model) Author: Jason Sherfey, PhD <jssherfey@gmail.com> Copyright (C) 2016 Jason Sherfey, Boston University, USA
0001 function [state_var_counts,monitor_counts] = dsGetOutputCounts(model) 0002 %GETOUTPUTCOUNTS - determine how many copies of each state variable and monitor will be produced by simulating the model. 0003 % 0004 % Usage: 0005 % [state_var_counts,monitor_counts]=dsGetOutputCounts(model) 0006 % 0007 % Author: Jason Sherfey, PhD <jssherfey@gmail.com> 0008 % Copyright (C) 2016 Jason Sherfey, Boston University, USA 0009 0010 state_var_counts=0; 0011 if ~isempty(model.state_variables) 0012 state_var_counts=zeros(1,length(model.state_variables)); 0013 for i=1:length(model.state_variables) 0014 state_var_counts(i)=dsGetPopSizeFromName(model,model.state_variables{i}); 0015 % parts=regexp(model.state_variables{i},'_','split'); 0016 % if numel(parts)==4 % has connection mechanism namespace: target_source_mechanism 0017 % % state variables defined in connection mechanisms are assumed to 0018 % % have dimensionality of the source population 0019 % part=parts{2}; 0020 % else % has intrinsic mechanism or population namespace: target_mechanism 0021 % % state variables defined in intrinsic mechanisms or population 0022 % % equations have dimensionality of the target population 0023 % part=parts{1}; 0024 % end 0025 % state_var_counts(i)=model.parameters.([part '_Npop']); 0026 end 0027 end 0028 monitor_counts=0; 0029 if ~isempty(model.monitors) 0030 monitor_names=fieldnames(model.monitors); 0031 monitor_counts=zeros(1,length(monitor_names)); 0032 for i=1:length(monitor_names) 0033 [~,~,target]=dsGetPopSizeFromName(model,monitor_names{i}); 0034 monitor_counts(i)=model.parameters.([target '_Npop']); 0035 % parts=regexp(monitor_names{i},'_','split'); 0036 % monitor_counts(i)=model.parameters.([parts{1} '_Npop']); 0037 end 0038 end