reverse-shooting

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

strmat.m (539B)


      1 % strmat.m   function y=strmat(a,endchar);
      2 %
      3 %  Accepts a 1xN string of variable names, separated by spaces, and creates
      4 %  a string matrix with each variable on a different row.
      5 
      6 function y=strmat(a,endchar);
      7 
      8 if exist('endchar')~=1; endchar=' '; end;
      9 
     10 y=[];
     11 start=1;
     12 M=length(a);
     13 if a(M)~=endchar; a=[a endchar]; end;
     14 N=1;
     15 
     16 for i=1:length(a);
     17   if a(i)==endchar;
     18     ypc=a(start:(i-1));
     19     if length(ypc)>N; 
     20       N=length(ypc); y=padspace(y,N);
     21     else;
     22       ypc=padspace(ypc,N);
     23     end;
     24     y=[y; ypc];
     25     start=i+1;
     26   end;
     27 end;