www.pudn.com > Closid30.rar > CLPRINT.M, change:1998-08-21,size:2603b


function clprint 
%this function prints figure fig such that the backgrounds are white 
%and the lines use linestyle ('-','-.','--',':','+','o','*','.','x' ). 
%In this black and white format the print command in the menubar of the 
%figure can be used to print. 
 
 
%author	 Peter Heuberger 
%			 Mechanical Engineering Systems and Control Group 
%         Delft University of Technology 
%version  2 
%date     23-7-1998 
 
if nargin==0, filenam=[]; fig=gcf; type='deps'; end 
if nargin==1, filenam=setstr(fig); fig=gcf;type='deps';end 
if nargin==2, type='deps';end 
if ~isempty(filenam), 
   if ~isstr(filenam), 
      error('file name must be a string'); 
   end 
end 
 
if ~isstr(type),error('type must be a string');end 
 
 
 
%check existence of figure 
if ishandle(fig), 
   k=strcmp('figure',get(fig,'type')); 
else, 
   k=0; 
end 
if ~k, error('given handle is not a figure handle');end 
 
%initialize memory variables 
oldcol=[]; 
oldstyl=[]; 
oldas=[]; 
order=str2mat('-','-.','--',':','+','o','*','.','x' ); 
if strcmp(get(fig,'inverthardcopy'),'off'), 
   set(fig,'inverthardcopy','on') 
   invert=1; 
else, 
   invert=0; 
end; 
    
figcol=get(fig,'color'); 
set(fig,'color',[0 0 0]); 
 
% get axes 
assen=findobj(fig,'type','axes'); 
nassen=	length(assen); 
if nassen>0, 
   xcol=zeros(nassen,3); 
   ycol=zeros(nassen,3); 
   zcol=zeros(nassen,3); 
   for ias=1:nassen, 
      has=assen(ias); 
      xcol(ias,:)=get(has,'xcolor'); 
      ycol(ias,:)=get(has,'ycolor'); 
      zcol(ias,:)=get(has,'zcolor'); 
      colas=get(has,'color'); 
      if isstr(colas), 
         colas=get(fig,'color'); 
      end 
      oldas=[oldas;has colas]; 
      set(has,'color',[0 0 0],'xcolor',[1 1 1],'ycolor',[1 1 1],'zcolor',[1 1 1]); 
      lines=findobj(has,'type','line'); 
	   nlines=length(lines); 
      if nlines>0, 
         ilineord=1; 
	      for iline=1:nlines, 
		      h=lines(iline); 
            oldcol=[h get(h,'color');oldcol]; 
            oldstyltmp=get(h,'linestyle'); 
            oldstyl=str2mat(oldstyltmp,oldstyl); 
            %now we take care for the difference in matlab 4.2 and 5.2 
            %in 4.2 markers have line style '*', 'o' etc 
            %in 4.2 markers have line style 'none' 
            if (strcmp(oldstyltmp,'none')|strcmp(oldstyltmp,'*')|strcmp(oldstyltmp,'+')|strcmp(oldstyltmp,'o')|strcmp(oldstyltmp,',')),   
               set(h,'color',[1 1 1]); 
            else, 
               set(h,'color',[1 1 1],'linestyle',deblank(order(ilineord,:))); 
               ilineord=ilineord+1; 
            end 
		   end 
		end 
	end 
end 
figure(fig)