⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fm_laprint.m

📁 这是一个很适合研究和学习用的电力系统仿真软件
💻 M
📖 第 1 页 / 共 5 页
字号:
    getfilenames(filename,'tex',verbose);
if ~strcmp(texdirname,epsdirname)
  fm_disp(['LaPrint Warning: eps-file and tex-file are placed in ' ...
           'different directories.'])  
  iswarning=1;
end  
if viewfile
  [viewfullnameext,viewbasenameext,viewbasename,viewdirname]= ...
      getfilenames(viewfilename,'tex',verbose);
  if strcmp(texfullnameext,viewfullnameext)
    fm_disp(['LaPrint Error: The tex- and view-file coincide. Use ' ...
             'different names.'],2)
    return
  end  
  if ~strcmp(texdirname,viewdirname)
    fm_disp(['LaPrint Warning: eps-file and view-file are placed '...
	   'in different directories.'])
    iswarning=1;
  end  
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%%%% PART 2 of advanced usage:
%%%% Create new figure, insert tags, and bookkeep original text
%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% open new figure (if required) and set properties

if ~nofigcopy
  figno=copyobj(figno,0);
  set(figno,'Numbertitle','off')
  set(figno,'MenuBar','none')
  pause(0.5)  
end  

if asonscreen
  xlimmodeauto=findobj(figno,'xlimmode','auto');
  xtickmodeauto=findobj(figno,'xtickmode','auto');
  xticklabelmodeauto=findobj(figno,'xticklabelmode','auto');
  ylimmodeauto=findobj(figno,'ylimmode','auto');
  ytickmodeauto=findobj(figno,'ytickmode','auto');
  yticklabelmodeauto=findobj(figno,'yticklabelmode','auto');
  zlimmodeauto=findobj(figno,'zlimmode','auto');
  ztickmodeauto=findobj(figno,'ztickmode','auto');
  zticklabelmodeauto=findobj(figno,'zticklabelmode','auto');
  set(xlimmodeauto,'xlimmode','manual')
  set(xtickmodeauto,'xtickmode','manual')
  set(xticklabelmodeauto,'xticklabelmode','manual')
  set(ylimmodeauto,'ylimmode','manual')
  set(ytickmodeauto,'ytickmode','manual')
  set(yticklabelmodeauto,'yticklabelmode','manual')
  set(zlimmodeauto,'ylimmode','manual')
  set(ztickmodeauto,'ytickmode','manual')
  set(zticklabelmodeauto,'yticklabelmode','manual')
end  
set(figno,'paperunits','centimeters');
set(figno,'units','centimeters');
%oripp=get(figno,'PaperPosition');
orip=get(figno,'Position');

if factor <= 0
  factor=width/orip(3);
end 
latexwidth=width;
epswidth=latexwidth/factor;
epsheight = epswidth*orip(4)/orip(3);

set(figno,'PaperPosition',[1 1 epswidth epsheight ])
set(figno,'Position',[orip(1)+0.5 orip(2)-0.5 epswidth epsheight ])
set(figno,'Name',[ 'To be printed; size: ' num2str(factor,3) ...
                   ' x (' num2str(epswidth,3) 'cm x ' num2str(epsheight,3) 'cm)' ])

asonscreen_dummy=0;
if asonscreen_dummy
  set(xlimmodeauto,'xlimmode','auto')
  set(xtickmodeauto,'xtickmode','auto')
  set(xticklabelmodeauto,'xticklabelmode','auto')
  set(ylimmodeauto,'ylimmode','auto')
  set(ytickmodeauto,'ytickmode','auto')
  set(yticklabelmodeauto,'yticklabelmode','auto')
  set(zlimmodeauto,'ylimmode','auto')
  set(ztickmodeauto,'ytickmode','auto')
  set(zticklabelmodeauto,'yticklabelmode','auto')
end

% some warnings
if directcall
  if (epswidth<13) | (epsheight<13*0.75)
    disp('warning: The size of the eps-figure is quite small.')
    disp('         The text objects might not be properly set.')
    disp('         Reducing ''factor'' might help.')
  end
  if latexwidth/epswidth<0.5
    disp([ 'warning: The size of the eps-figure is large compared ' ...
           'to the latex figure.' ])
    disp('         The text size might be too small.')
    disp('         Increasing ''factor'' might help.')
  end  
  if (orip(3)-epswidth)/orip(3) > 0.1
    disp(['warning: The size of the eps-figure is much smaller '...
	  'than the original'])
    disp('         figure on screen. Matlab might save different ticks and')
    disp([ '         ticklabels than in the original figure. See option ' ...
           '''asonsceen''. ' ])
  end
end  

if verbose
  disp('Strike any key to continue.');
  pause
end  

%
% TEXT OBJECTS: modify new figure 
%

% find all text objects
hxl=get(findobj(figno,'type','axes'),'xlabel');
hyl=get(findobj(figno,'type','axes'),'ylabel');
hzl=get(findobj(figno,'type','axes'),'zlabel');
hti=get(findobj(figno,'type','axes'),'title');
hte=findobj(figno,'type','text');
% array of all text handles
htext=unique([ celltoarray(hxl) celltoarray(hyl) celltoarray(hzl) ...
               celltoarray(hti) celltoarray(hte)]);
nt=length(htext);

% generate new strings and store old ones
oldstr=get(htext,'string');
newstr=cell(nt,1);
basestr='str00';
for i=1:nt
  if isa(oldstr{i},'cell')
    if length(oldstr{i})>1
      disp('LaPrint warning: Annotation in form of a cell is currently')
      disp('         not supported. Ignoring all but first component.')
      iswarning=1;
    end
    % To do: place a parbox here. 
    oldstr{i}=oldstr{i}{1};
  end  
  if size(oldstr{i},1)>1
    disp([ 'LaPrint warning: Annotation in form of string matrices ' ...
           'is currently not supported.' ])
    disp('         Ignoring all but first row.')
    iswarning=1;
    % To do: place a parbox here. 
    oldstr{i}=oldstr{i}(1,:);
  end  
  if length(oldstr{i})
    oldstr{i}=strrep(strrep(oldstr{i},'\','\\'),'%','%%');
    newstr{i} = overwritetail(basestr,i);
  else  
    newstr{i}='';    
  end
end

% replace strings in figure
for i=1:nt
  set(htext(i),'string',newstr{i});
  %set(htext(i),'visible','on');
end    

% get alignments
hora=get(htext,'HorizontalAlignment');
vera=get(htext,'VerticalAlignment');
align=cell(nt,1);
for i=1:nt
  align{i}=hora{i}(1);
  if strcmp(vera{i},'top')
    align{i}=[align{i} 't'];
  elseif strcmp(vera{i},'cap')
    align{i}=[align{i} 't'];
  elseif strcmp(vera{i},'middle')
    align{i}=[align{i} 'c'];
  elseif strcmp(vera{i},'baseline')
    align{i}=[align{i} 'B'];
  elseif strcmp(vera{i},'bottom')
    align{i}=[align{i} 'b'];
  end
end  

% get font properties and create commands
if nt > 0
  [fontsizecmd{1:nt}] = deal('');
  [fontanglecmd{1:nt}] = deal('');
  [fontweightcmd{1:nt}] = deal('');
end
selectfontcmd='';

if keepfontprops

  % fontsize
  set(htext,'fontunits','points');
  fontsize=get(htext,'fontsize');
  for i=1:nt
    fontsizecmd{i}=[ '\\fontsize{' num2str(fontsize{i}) '}{' ...
                     num2str(fontsize{i}*1.5) '}'  ];
  end
  
  % fontweight
  fontweight=get(htext,'fontweight');
  for i=1:nt
    if strcmp(fontweight{i},'light')
      fontweightcmd{i}=[ '\\fontseries{l}\\mathversion{normal}' ];
    elseif strcmp(fontweight{i},'normal')
      fontweightcmd{i}=[ '\\fontseries{m}\\mathversion{normal}' ];
    elseif strcmp(fontweight{i},'demi')
      fontweightcmd{i}=[ '\\fontseries{sb}\\mathversion{bold}' ];
    elseif strcmp(fontweight{i},'bold')
      fontweightcmd{i}=[ '\\fontseries{bx}\\mathversion{bold}' ];
    else
      disp([ ' LaPrint warning: unknown fontweight:' fontweight{i} ])
      iswarning=1;
      fontweightcmd{i}=[ '\\fontseries{m}\\mathversion{normal}' ];
    end
  end  

  % fontangle
  fontangle=get(htext,'fontangle');
  for i=1:nt
    if strcmp(fontangle{i},'normal')
      fontanglecmd{i}=[ '\\fontshape{n}' ];
    elseif strcmp(fontangle{i},'italic')
      fontanglecmd{i}=[ '\\fontshape{it}' ];
    elseif strcmp(fontangle{i},'oblique')
      fontangle{i}=[ '\\fontshape{it}' ];
    else
      disp([ ' LaPrint warning: unknown fontangle:' fontangle{i} ])
      iswarning=1;
      fontanglecmd{i}=[ '\\fontshape{n}' ];
    end
  end  
  selectfontcmd= '\\selectfont ';
  
end

%
% LABELS: modify new figure
%

if ~keepticklabels

  % all axes
  hax=celltoarray(findobj(figno,'type','axes'));
  na=length(hax);

  if directcall
    % try to figure out if we have 3D axes an warn
    issuewarning=0;
    for i=1:na
      issuewarning=max(issuewarning,is3d(hax(i)));
    end
    if issuewarning
      disp('LaPrint warning: There seems to be a 3D plot. The LaTeX labels are')
      disp('         possibly incorrect. The option  ''keepticklabels'' might')
      disp('         help. The option ''nofigcopy'' might be wise, too.')
    end
  end  

  % try to figure out if we linear scale with extra factor 
  % and determine powers of 10
  powers=NaN*zeros(na,3);  % matrix with powers of 10 
  for i=1:na                    % all axes
    allxyz={ 'x', 'y', 'z' };
    for ixyz=1:3                % x,y,z
      xyz=allxyz{ixyz};
      ticklabelmode=get(hax(i),[ xyz 'ticklabelmode']);
      if strcmp(ticklabelmode,'auto')
        tick=get(hax(i),[ xyz 'tick']);
        ticklabel=get(hax(i),[ xyz 'ticklabel']);	      
	nticks=size(ticklabel,1);
	if nticks==0,
          powers(i,ixyz)=0;
	end  
        for k=1:nticks        % all ticks
	  label=str2num(ticklabel(k,:));
	  if length(label)==0, 
	    powers(i,ixyz)=0;
	    break; 
	  end  
	  if ( label==0 ) & ( abs(tick(k))>1e-10 )
	    powers(i,ixyz)=0;
	    break; 
          end	      
	  if label~=0    
            expon=log10(tick(k)/label);
	    rexpon=round(expon);
	    if abs(rexpon-expon)>1e-10
              powers(i,ixyz)=0;
	      break; 
	    end	
            if isnan(powers(i,ixyz))
	      powers(i,ixyz)=rexpon;
	    else 	
	      if powers(i,ixyz)~=rexpon
        	powers(i,ixyz)=0;
	        break; 
              end		
	    end 
          end  	    
	end % k	    
      else % if 'auto'
        powers(i,ixyz)=0;
      end % if 'auto'
    end % ixyz
  end % i
  
  % replace all ticklabels and bookkeep
  nxlabel=zeros(1,na);
  nylabel=zeros(1,na);
  nzlabel=zeros(1,na);
  allxyz={ 'x', 'y', 'z' };
  for ixyz=1:3
    xyz=allxyz{ixyz};
    k=1;
    basestr=[ xyz '00' ];
    if strcmp(xyz,'y') % 'y' is not horizontally centered! 
      basestr='v00';
    end  
    oldtl=cell(na,1);
    newtl=cell(na,1);
    nlabel=zeros(1,na);
    for i=1:na
      % set(hax(i),[ xyz 'tickmode' ],'manual')
      % set(hax(i),[ xyz 'ticklabelmode' ],'manual')
      oldtl{i}=chartocell(get(hax(i),[ xyz 'ticklabel' ]));
      nlabel(i)=length(oldtl{i});
      newtl{i}=cell(1,nlabel(i));
      for j=1:nlabel(i)
        newtl{i}{j} = overwritetail(basestr,k);
        k=k+1;
        oldtl{i}{j}=deblank(strrep(strrep(oldtl{i}{j},'\','\\'),'%','%%'));
      end
      set(hax(i),[ xyz 'ticklabel' ],newtl{i});
    end  
    eval([ 'old' xyz 'tl=oldtl;' ]);
    eval([ 'new' xyz 'tl=newtl;' ]);
    eval([ 'n' xyz 'label=nlabel;' ]);
  end

  % determine latex commands for font properties
  
  if keepfontprops

    % font size
    afsize=zeros(na,1);
    for i=1:na
      afsize(i)=get(hax(i),'fontsize');
    end          
    if (any(afsize ~= afsize(1) ))
      disp('LaPrint warning: Different font sizes for axes not supported.')
      disp([ '         All axses will have font size ' ...
	     num2str(afsize(1)) '.' ] )
      iswarning=1;
    end      
    afsizecmd = [ '\\fontsize{' num2str(afsize(1)) '}{' ...
                  num2str(afsize(1)*1.5) '}'  ];

    % font weight
    afweight=cell(na,1);
    for i=1:na
      afweight{i}=get(hax(i),'fontweight');
    end
    if strcmp(afweight{1},'light')
      afweightcmd=[ '\\fontseries{l}\\mathversion{normal}' ];
    elseif strcmp(afweight{1},'normal')
      afweightcmd=[ '\\fontseries{m}\\mathversion{normal}' ];
    elseif strcmp(afweight{1},'demi')
      afweightcmd=[ '\\fontseries{sb}\\mathversion{bold}' ];
    elseif strcmp(afweight{1},'bold')
      afweightcmd=[ '\\fontseries{bx}\\mathversion{bold}' ];
    else
      disp([ ' LaPrint warning: unknown fontweight:' afweight{1} ])
      iswarning=1;
      afweightcmd=[ '\\fontseries{m}\\mathversion{normal}' ];
    end
    for i=1:na
      if ~strcmp(afweight{i},afweight{1})
        disp(' LaPrint warning: Different font weights for axes not')
        disp([ '      supported. All axes will have font weight ' afweightcmd])
        iswarning=1;
      end      
    end      

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -