reverse-shooting

Matlab scripts for reverse shooting
Log | Files | Refs | README

interplin2.m (797B)


      1 function [newx,newyrs]=interplin(x,yrs)
      2 
      3 % interplin2
      4 %
      5 %   Simple linear interpolation
      6 %
      7 %    x=initial vector/matrix (will interpolate each column)
      8 %    yrs=The years corresponding to the x data -- will interpolate
      9 %    annually.  E.g. 1960 10
     10 %                    1965 15
     11 %                    1967 14
     12 %    This will provide interpolations for 1961-64 and 1966
     13 
     14 [T K]=size(x);
     15 if T==1; x=x'; T=length(x); end;  % row vector ==> column vector
     16 
     17 blah=ones(1,K);
     18 x=[yrs x]; 	% Reform, so we interpolate yrs as we go!
     19 y=x(1,:);
     20 
     21 for i=1:(T-1);     % position in x
     22   points=yrs(i+1)-yrs(i)-1;
     23   if points>0;
     24 	slope=x(i+1,:)-x(i,:);
     25 	step=slope/(points+1);
     26 	dx=mult(blah,step);
     27 	dx=kron((1:points)',dx);
     28 	y=[y; pluschad(dx,x(i,:))];
     29   end;
     30   y=[y; x(i+1,:)];
     31 end;
     32 
     33 newx=y(:,2:(K+1));
     34 newyrs=y(:,1);
     35 	
     36