reverse-shooting

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

cshow.m (1639B)


      1 % CSHOW.m   []=cshow(text,data,fmt,tle,latex)
      2 %	Displays text and data...
      3 %       tle='Year H/Y LifeExp':  will display over the columns.
      4 %       latex='latex':  will display twice, once with & data & \\ and without.
      5 
      6 function []=cshow(text,data,fmt,tle,latex);
      7 
      8 if iscell(text);  % If it's a cell instead of a string.  Convert
      9   % Create strmat version of text for cshow
     10   a=text(1);
     11   for i=2:length(text);
     12     a=[a '#' text(i)];
     13   end;
     14   text=strmat(cell2mat(a),'#');
     15 end;
     16 
     17 
     18 if exist('fmt')==0; fmt='%12.8f'; end;
     19 if exist('latex')==0;  latex='nonee'; end;
     20 if exist('tle')~=0; 
     21   if ~isempty(tle);   tle=strmat(tle); end; 
     22 else;
     23   tle=[];
     24 end;
     25 
     26 NumLoops=1; if latex=='latex'; NumLoops=2; end;
     27   
     28 for NN=NumLoops:-1:1;
     29 
     30 
     31 if ~isempty(tle);
     32   disp ' '; disp ' ';
     33   ctr=0;
     34   if text(1,1)~=' '; 
     35     spc=size(text,2);
     36     ctr=ctr+spc;
     37     fprintf(1,['%' num2str(spc) 's'],' '); 
     38   end;
     39   blah=strmat(fmt);
     40   blah=replace(blah,blah=='.','s');
     41   for i=1:size(tle,1);
     42     j=size(blah,1);
     43     if i<j; j=i; end;
     44     indx=find(blah(j,:)=='s');
     45     len=str2num(blah(j,2:indx-1));
     46     ctr=ctr+len;
     47     indx2=find(tle(i,:)==' ')-1; if isempty(indx2); indx2=length(tle(i,:)); end;
     48     fprintf(1,['%' num2str(len) 's'],tle(i,1:indx2));
     49   end;
     50   fprintf(1,'\n');
     51   disp(char(kron('-',ones(1,ctr))));
     52 end;
     53 
     54 
     55 [n k] = size(data);
     56 blah=strmat(fmt);
     57 for i=1:n;
     58   if text(1,1)~=' '; fprintf(1,text(i,:)); end;
     59   for k=1:size(data,2);
     60     if NN==2; fprintf(1,' &'); end;
     61     j=size(blah,1);
     62     if k<j; j=k; end;
     63     fprintf(1,cutspace(blah(j,:)),data(i,k));
     64   end;
     65   if NN==2; fprintf(1,'\\\\'); end;
     66   fprintf(1,'\n');
     67 end % i loop
     68 
     69 
     70 end;  % NN latex loop
     71 
     72