User Tools

Site Tools


mfiles:mfiles

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
mfiles:mfiles [2010/12/13 15:22] lennartfrmfiles:mfiles [2010/12/13 15:34] (current) lennartfr
Line 1113: Line 1113:
  
 ====== Files written autumn 2010 ====== ====== Files written autumn 2010 ======
 +
 +==== table2allCohortsModel.m ====
 +
 +<file txt table2allCohortsModel.m>
 +function table2allCohortsModel(startyear, endyear, minage, maxage, catchfile, ...
 +     surveyfile, datfile, include_weight_maturity);
 +% table2allCohortsModel(startyear, endyear, minage, maxage, catchfile, surveyfile, datfile, include_weight_and_maturity);
 +
 +
 +fid = fopen(datfile,'w');
 +
 +try,
 +  fprintf(fid,'# Auto-generated datfile\n\n');
 +
 +  fprintf(fid,'# Startyear\n%i\n\n# Endyear\n%i\n\n',startyear,endyear);
 +
 +  fprintf(fid,'# Min age\n%i\n\n# Max age\n%i\n\n',minage,maxage);
 +
 +  fprintf(fid,'# Catch\n');
 +
 +  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:endyear_row),
 +    for (j=minage_col:maxage_col),
 +      fprintf(fid,'%10.6f ',C(i,j));
 +    end;
 +    fprintf(fid,'\n');
 +  end;
 +  
 +  
 +  fprintf(fid,'# Survey data\n');
 +  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:endyear_row),
 +    for (j=minage_col:maxage_col),
 +      fprintf(fid,'%10.6f ',S(i,j));
 +    end;
 +    fprintf(fid,'\n');
 +  end;
 +  
 +  if (exist('include_weight_maturity','var') && include_weight_maturity == 1),
 +    
 +    mature_3_12_2009;
 +    weight_3_11_2009;
 +    mature = mature';
 +    weight = weight';
 +    
 +    fprintf(fid,'# Proportion mature at age\n');
 +    startyear_row = find(mature(:,1) == startyear);
 +    endyear_row = find(mature(:,1) == endyear);
 +    
 +    minage_col = find(mature(1,:) == minage);
 +    maxage_col = find(mature(1,:) == maxage);
 +    
 +    for (i=startyear_row:endyear_row),
 +      for (j=minage_col:maxage_col),
 + fprintf(fid,'%10.6f ',mature(i,j));
 +      end;
 +      fprintf(fid,'\n');
 +    end;
 +    
 +    
 +    
 +    fprintf(fid,'# Weight at age\n');
 +    startyear_row = find(weight(:,1) == startyear);
 +    endyear_row = find(weight(:,1) == endyear);
 +    
 +    minage_col = find(weight(1,:) == minage);
 +    maxage_col = find(weight(1,:) == maxage);
 +    
 +    for (i=startyear_row:endyear_row),
 +      for (j=minage_col:maxage_col),
 + fprintf(fid,'%10.6f ',weight(i,j));
 +      end;
 +      fprintf(fid,'\n');
 +    end;
 +    
 +    get_sondre_data;
 +    csd = [nan sondre_ages; sondre_years' sondre_sigma];
 +    
 +    fprintf(fid,'# Catch standard deviations\n');
 +    startyear_row = find(csd(:,1) == startyear);
 +    endyear_row = find(csd(:,1) == endyear);
 +    
 +    minage_col = find(csd(1,:) == minage);
 +    maxage_col = find(csd(1,:) == maxage);
 +    
 +    for (i=startyear_row:endyear_row),
 +      for (j=minage_col:maxage_col),
 + fprintf(fid,'%10.6f ',csd(i,j));
 +      end;
 +      fprintf(fid,'\n');
 +    end;
 +    
 +    
 +  end;
 +  
 +  
 +  fclose(fid);
 +
 +catch,
 +  fprintf(2,'%s\n',lasterr);
 +  fclose(fid);
 +end;
 +
 +
 +</file>
mfiles/mfiles.txt · Last modified: 2010/12/13 15:34 by lennartfr