try, more off; end; % number of replications per choice for cfactor numreps = 1; % cfs contains the cfactor choices %cfs = [0.3 0.6 0.9 1.2 1.5]; cfs = [5]; ns = length(cfs); cod_dir = '../cod_admb'; base_dir = pwd; filename = [cod_dir '/cod']; results = cell(ns,1); for (ii=1:ns), results{ii} = zeros(4,numreps); for (jj=1:numreps), % Generate data Nt = generate_data([500 ],0.5,0.1,0.15,'../cod_admb/cod',1,15,1,1*14*1,1980,cfs(ii)); % Run the exp cd(cod_dir); pause(0.1); unix('./cod'); pause(0.1); cd(base_dir); % save the data try, extractpar; results{ii}(1,jj) = N0(1); results{ii}(2,jj) = q(1); results{ii}(3,jj) = M; results{ii}(4,jj) = exp(logs); end; end; end; names = {'N0','q','M','s'}; % Plotting command: for (i=1:length(cfs)), figure; plot(sort(results{i}(1,:))); hold on; plot([1 100], [1 1]*median(sort(results{i}(1,:))),'r'); title(sprintf('cfactor = %s',num2str(cfs(i)))); xlabel('Replication number (sorted)'); ylabel('Estimated N0 and median'); plot([1 100],[0.500 0.500],'g'); legend('Estimates','Median','True N0','Location','NorthWest') end; % Example command for saving image % print(gcf,'-dpng','../images_for_wiki/montecarlo_cfactor_test.png')