reverse-shooting

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

interplin.m (626B)


      1 function y=interplin(x,points)
      2 
      3 % interplin
      4 %
      5 %   Simple linear interpolation
      6 %
      7 %    x=initial vector/matrix (will interpolate each column)
      8 %    points=number of points to add between each row.
      9 
     10 [T K]=size(x);
     11 if T==1; x=x'; T=length(x); end;  % row vector ==> column vector
     12 
     13 y=zeros(T*(points+1),K);
     14 blah=mult(ones(points+1,K),(0:points)');
     15 
     16 yi=1;           % position in y
     17 for xi=1:(T-1);     % position in x
     18 	slope=x(xi+1,:)-x(xi,:);
     19 	step=slope/(points+1);
     20 	data=mult(blah,step);
     21 	data=plus(data,x(xi,:));
     22 	y(yi:(yi+points),:)=data;
     23 	yi=yi+points+1;
     24 end;
     25 y(yi,:)=x(T,:);
     26 y=trimr(y,0,points);    % pull off the last few
     27 	
     28