mfiles:mfiles
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
mfiles:mfiles [2010/05/05 13:20] – lennartfr | mfiles:mfiles [2010/12/13 15:34] (current) – lennartfr | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Matlab / Octave Utilities ====== | ====== Matlab / Octave Utilities ====== | ||
+ | |||
+ | This page list the various Matlab and octave utilities which interact with ADMB, typically generating input for and interpreting output from ADMB. It is meant to be as complete as possible. This means that it is likely to contain many non-essential files as well as the essential files, for defining and running data sets. | ||
+ | |||
+ | ====== Files written spring 2010 ====== | ||
Here various .m-files which interact with ADMB will be listed. | Here various .m-files which interact with ADMB will be listed. | ||
Line 18: | Line 22: | ||
% Enter the proper directory | % Enter the proper directory | ||
- | cd ~lennartfr/ | + | %cd ~lennartfr/ |
% Define data files | % Define data files | ||
Line 41: | Line 45: | ||
% Run ADMB | % Run ADMB | ||
- | unix(' | + | unix('unset LD_LIBRARY_PATH; |
% Return to mfile directory and plot | % Return to mfile directory and plot | ||
Line 61: | Line 65: | ||
% Enter the proper directory | % Enter the proper directory | ||
- | cd ~lennartfr/ | + | % cd ~lennartfr/ |
% Define parameters for data generation | % Define parameters for data generation | ||
Line 88: | Line 92: | ||
% Run ADMB | % Run ADMB | ||
- | unix(' | + | unix('unset LD_LIBRARY_PATH; |
% Return to mfile directory and plot | % Return to mfile directory and plot | ||
Line 139: | Line 143: | ||
==== datpar2plot.m ==== | ==== datpar2plot.m ==== | ||
<file txt datpar2plot.m> | <file txt datpar2plot.m> | ||
+ | function datpar2plot(filename, | ||
% datpar2plot(filename, | % datpar2plot(filename, | ||
% | % | ||
Line 161: | Line 166: | ||
%who(' | %who(' | ||
extractstd; | extractstd; | ||
+ | |||
%whos(' | %whos(' | ||
std_coeff = 1.96; | std_coeff = 1.96; | ||
% Get first year from dat file. | % Get first year from dat file. | ||
+ | [filename ' | ||
[m, | [m, | ||
firstyear = startyears(1); | firstyear = startyears(1); | ||
Line 192: | Line 198: | ||
plot(firstyear+(i-1): | plot(firstyear+(i-1): | ||
try, | try, | ||
- | errorbar(firstyear+(i-1), | + | |
% | % | ||
- | % ERRORBAR doesn' | + | % ERRORBAR doesn' |
- | | + | plot([ firstyear+(i-1) ; firstyear+(i-1)], |
catch, | catch, | ||
- | %fprintf(2,' | + | %fprintf(2,' |
%disp(lasterr); | %disp(lasterr); | ||
errorbar(firstyear+(i-1), | errorbar(firstyear+(i-1), | ||
Line 213: | Line 219: | ||
if (exist(' | if (exist(' | ||
q_sigmoid = q0 * ((exp(q_alpha*survey(i, | q_sigmoid = q0 * ((exp(q_alpha*survey(i, | ||
+ | | ||
plot(startyears(survey(i, | plot(startyears(survey(i, | ||
(1/ | (1/ | ||
Line 227: | Line 233: | ||
else, | else, | ||
- | plot(startyears(survey(i, | + | plot(startyears(survey(i, |
- | [colors{survey(i, | + | |
end; | end; | ||
- | |||
end; | end; | ||
Line 238: | Line 242: | ||
ylabel(' | ylabel(' | ||
- | curr_axis = axis; | + | %curr_axis = axis; |
- | axis([curr_axis(1) curr_axis(2) 0 2500/ | + | %try, |
+ | % | ||
+ | %catch, | ||
+ | % axis([curr_axis(1) curr_axis(2) 0 2500/ | ||
+ | %end; | ||
hold off; | hold off; | ||
+ | |||
+ | % If q is a sigmoid function, plot this function | ||
+ | if (exist(' | ||
+ | |||
+ | sf = figure; | ||
+ | xx = 0:1:20; | ||
+ | yy = q0 * (exp(q_alpha*xx+q_beta)./ | ||
+ | plot(xx, | ||
+ | title(' | ||
+ | xlabel(' | ||
+ | ylabel(' | ||
+ | |||
+ | end; | ||
+ | |||
+ | |||
return; | return; | ||
Line 315: | Line 338: | ||
% Send the variable name and values to the command line | % Send the variable name and values to the command line | ||
eval(sprintf(' | eval(sprintf(' | ||
+ | %sprintf(' | ||
end; | end; | ||
Line 335: | Line 358: | ||
output = fgetl(fid); | output = fgetl(fid); | ||
- | N_cell{i} = str2double(output); | + | N_cell{i} = str2num(output); |
max_width_so_far = max(max_width_so_far, | max_width_so_far = max(max_width_so_far, | ||
Line 1087: | Line 1110: | ||
fclose(fid); | fclose(fid); | ||
end; | end; | ||
+ | </ | ||
+ | |||
+ | ====== Files written autumn 2010 ====== | ||
+ | |||
+ | ==== table2allCohortsModel.m ==== | ||
+ | |||
+ | <file txt table2allCohortsModel.m> | ||
+ | function table2allCohortsModel(startyear, | ||
+ | surveyfile, datfile, include_weight_maturity); | ||
+ | % table2allCohortsModel(startyear, | ||
+ | |||
+ | |||
+ | fid = fopen(datfile,' | ||
+ | |||
+ | try, | ||
+ | fprintf(fid,'# | ||
+ | |||
+ | fprintf(fid,'# | ||
+ | |||
+ | fprintf(fid,'# | ||
+ | |||
+ | fprintf(fid,'# | ||
+ | |||
+ | C = load(catchfile); | ||
+ | |||
+ | startyear_row = find(C(:,1) == startyear); | ||
+ | endyear_row = find(C(:,1) == endyear); | ||
+ | | ||
+ | minage_col = find(C(1,:) == minage); | ||
+ | maxage_col = find(C(1,:) == maxage); | ||
+ | | ||
+ | for (i=startyear_row: | ||
+ | for (j=minage_col: | ||
+ | fprintf(fid,' | ||
+ | end; | ||
+ | fprintf(fid,' | ||
+ | end; | ||
+ | | ||
+ | | ||
+ | fprintf(fid,'# | ||
+ | S = load(surveyfile); | ||
+ | | ||
+ | startyear_row = find(S(:,1) == startyear); | ||
+ | endyear_row = find(S(:,1) == endyear); | ||
+ | | ||
+ | minage_col = find(S(1,:) == minage); | ||
+ | maxage_col = find(S(1,:) == maxage); | ||
+ | | ||
+ | for (i=startyear_row: | ||
+ | for (j=minage_col: | ||
+ | fprintf(fid,' | ||
+ | end; | ||
+ | fprintf(fid,' | ||
+ | end; | ||
+ | | ||
+ | if (exist(' | ||
+ | | ||
+ | mature_3_12_2009; | ||
+ | weight_3_11_2009; | ||
+ | mature = mature'; | ||
+ | weight = weight'; | ||
+ | | ||
+ | fprintf(fid,'# | ||
+ | startyear_row = find(mature(:, | ||
+ | endyear_row = find(mature(:, | ||
+ | | ||
+ | minage_col = find(mature(1,: | ||
+ | maxage_col = find(mature(1,: | ||
+ | | ||
+ | for (i=startyear_row: | ||
+ | for (j=minage_col: | ||
+ | fprintf(fid,' | ||
+ | end; | ||
+ | fprintf(fid,' | ||
+ | end; | ||
+ | | ||
+ | | ||
+ | | ||
+ | fprintf(fid,'# | ||
+ | startyear_row = find(weight(:, | ||
+ | endyear_row = find(weight(:, | ||
+ | | ||
+ | minage_col = find(weight(1,: | ||
+ | maxage_col = find(weight(1,: | ||
+ | | ||
+ | for (i=startyear_row: | ||
+ | for (j=minage_col: | ||
+ | fprintf(fid,' | ||
+ | end; | ||
+ | fprintf(fid,' | ||
+ | end; | ||
+ | | ||
+ | get_sondre_data; | ||
+ | csd = [nan sondre_ages; | ||
+ | | ||
+ | fprintf(fid,'# | ||
+ | startyear_row = find(csd(:, | ||
+ | endyear_row = find(csd(:, | ||
+ | | ||
+ | minage_col = find(csd(1,: | ||
+ | maxage_col = find(csd(1,: | ||
+ | | ||
+ | for (i=startyear_row: | ||
+ | for (j=minage_col: | ||
+ | fprintf(fid,' | ||
+ | end; | ||
+ | fprintf(fid,' | ||
+ | end; | ||
+ | | ||
+ | | ||
+ | end; | ||
+ | | ||
+ | | ||
+ | fclose(fid); | ||
+ | |||
+ | catch, | ||
+ | fprintf(2,' | ||
+ | fclose(fid); | ||
+ | end; | ||
+ | |||
+ | |||
</ | </ |
mfiles/mfiles.1273065622.txt.gz · Last modified: 2010/05/05 13:20 by lennartfr