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

📄 alternator.m

📁 关于电机的.m程序
💻 M
字号:
%   ALTERNATOR
clc,clear,close all
disp(date)
info= ...
        ['                   ALTERNATOR                       '
         'The elementary 3-phase 2-pole synchronous generator '
         'has a stator equipped with 3 coils displaced 120o   '
         'from each other;although shown as concentrated, they'
         'actually are distributed.                           '
         'When the rotor is excited with dc and rotated, the  '
         'resultant field will also rotate so that sinusoidal '
         'voltages are generated in the three stator phases,  '
         'displaced 120o in time and having a frequency       '
         'directly related to rotor speed.                    '
         '                                                    '];                                       
         
disp(info)
warning off MATLAB:mir_warning_variable_used_as_function
avialt=avifile('alternatormovie.avi','compression','cinepak');
n=100;dphi=2*pi/n;phis=pi/2;phim=0;g=pi/3;e=0;r1=.62;alpha=2*pi/3;s=1.3;ds=(3.7-1.3)/24;r2=.8;r3=.5;
%
 figure('units','normalized','Position',[.25 .1 .73 .73],'Name','ALTERNATOR',...
        'NumberTitle','off');
 set(gcf,'color','w')      
    for k=1:n
            
      Fa1=r1*cos(phis);Fb1=r1*sin(phis);
      Fa2=r1*cos(phis+g);Fb2=r1*sin(phis+g);
      Fa3=r1*cos(phis+2*g);Fb3=r1*sin(phis+2*g);
      Fa4=r1*cos(phis+3*g);Fb4=r1*sin(phis+3*g);
      Fa5=r1*cos(phis+4*g);Fb5=r1*sin(phis+4*g);
      Fa6=r1*cos(phis+5*g);Fb6=r1*sin(phis+5*g);
      
      theta=0:pi/30:2*pi; 
      q=1.3:(3.7-1.3)/(length(theta)-1):3.7;
      fA=cos(theta);
      fB=cos(theta-alpha);
      fC=cos(theta+alpha);
      fAo=cos(phim);
      fBo=cos(phim-alpha);
      fCo=cos(phim+alpha);
      tA=abs(fAo);
      tB=abs(fBo);
      tC=abs(fCo);
      p=[0:pi/20:2*pi];
      X= r2*cos(p) ;Y=r2*sin(p);       
      x=r3*cos(p) ;y=r3*sin(p);
     
      d3=.45*sqrt(2)/2;
      x3=[.45*cos([pi/4:pi/20:3*pi/4]) -d3 -.25 -.25 .45*cos([5*pi/4:pi/20:7*pi/4]) .25 .25 d3];
      y3=[.45*sin([pi/4:pi/20:3*pi/4]) d3 d3 -d3 .45*sin([5*pi/4:pi/20:7*pi/4]) -d3 d3 d3];
      fill(X,Y,[.7 .7 .7],'linewidth',1.5),hold on
      fill(x,y,[1 1 1],'linewidth',1.5)
      h3=fill(x3,y3,[.7 .7 .7],'linewidth',1.5);
      rotate(h3,[0 0 1],e,[0 0 0])
           
      h1=fill([.25 .4 .4 .25 .25],[-.2 -.2 .2 .2 -.2],'c');
      rotate(h1,[0 0 1],e,[0 0 0])
      h2=fill([-.4 -.25 -.25 -.4 -.4],[-.2 -.2 .2 .2 -.2],'c');
      rotate(h2,[0 0 1],e,[0 0 0])
      h4=plot([.25 .4],[-.2 .2],'k',[.4 .25],[-.2 .2],'k','LineWidth',1);
      rotate(h4,[0 0 1],e,[0 0 0])
      h6=plot([-.4 -.25],[-.2 .2],'k',[-.25 -.4],[-.2 .2],'k','LineWidth',1);
      rotate(h6,[0 0 1],e,[0 0 0])
      h5=plot([-.05 -.05 .05 .05],[.2 .35 .2 .35],'k','LineWidth',1.5);
      rotate(h5,[0 0 1],e,[0 0 0])
      h7=plot([-.05 0 .05 -.05 0 .05],[-.3 -.35 -.3 -.2 -.15 -.2],'k','LineWidth',1.5);
      rotate(h7,[0 0 1],e,[0 0 0])
            
      fa1=.32*cos(phim);fb1=.32*sin(phim);
      plot(fa1,fb1,'kx','MarkerSize',8,'linewidth',1.5)
      fa2=.32*cos(phim+pi);fb2=.32*sin(phim+pi);
      plot(fa2,fb2,'k.','MarkerSize',10)
      
      plot(Fa1,Fb1,'ro','MarkerSize',14,'MarkerEdgeColor','k','MarkerFacecolor','w')
      plot(Fa1,Fb1,'ro','MarkerSize',tA*12,'MarkerFacecolor','r')
      if fAo>0
        plot(Fa1,Fb1,'k.','MarkerSize',10,'LineWidth',3)
      else    
        plot(Fa1,Fb1,'kx','MarkerSize',10,'LineWidth',2)
      end  
      
      plot(Fa2,Fb2,'bo','MarkerSize',14,'MarkerEdgeColor','k','MarkerFacecolor','w')
      plot(Fa2,Fb2,'bo','MarkerSize',tC*12,'MarkerFacecolor','b')
      if fCo>0
        plot(Fa2,Fb2,'kx','MarkerSize',10,'LineWidth',3)
      else    
        plot(Fa2,Fb2,'k.','MarkerSize',10,'LineWidth',2)
      end  
      
      plot(Fa3,Fb3,'go','MarkerSize',14,'MarkerEdgeColor','k','MarkerFacecolor','w')
      plot(Fa3,Fb3,'go','MarkerSize',tB*12,'MarkerFacecolor','g')
      if fBo>0
        plot(Fa3,Fb3,'k.','MarkerSize',10,'LineWidth',3)
      else    
        plot(Fa3,Fb3,'kx','MarkerSize',10,'LineWidth',2)
      end  
     
      plot(Fa4,Fb4,'ro','MarkerSize',14,'MarkerEdgeColor','k','MarkerFacecolor','w')
      plot(Fa4,Fb4,'ro','MarkerSize',tA*12,'MarkerFacecolor','r')
      if fAo<0
        plot(Fa4,Fb4,'k.','MarkerSize',10,'LineWidth',3)
      else    
        plot(Fa4,Fb4,'kx','MarkerSize',10,'LineWidth',2)
      end  
      
      plot(Fa5,Fb5,'bo','MarkerSize',14,'MarkerEdgeColor','k','MarkerFacecolor','w')
      plot(Fa5,Fb5,'bo','MarkerSize',tC*12,'MarkerFacecolor','b')
      if fCo<0
        plot(Fa5,Fb5,'kx','MarkerSize',10,'LineWidth',3)
      else    
        plot(Fa5,Fb5,'k.','MarkerSize',10,'LineWidth',2)
      end  
      
      plot(Fa6,Fb6,'go','MarkerSize',14,'MarkerEdgeColor','k','MarkerFacecolor','w')
      plot(Fa6,Fb6,'go','MarkerSize',tB*12,'MarkerFacecolor','g')
      if fBo<0
        plot(Fa6,Fb6,'k.','MarkerSize',10,'LineWidth',3)
      else    
        plot(Fa6,Fb6,'kx','MarkerSize',10,'LineWidth',2)
      end  
      %plot(Fa6,Fb6,'kx','MarkerSize',10)
      
      fill([1.3 3.7 3.7 1.3 1.3],[-1.1 -1.1 1.1 1.1 -1.1],[1 1 1],'linewidth',1.5)
      
      text(.5,1.4,'ALTERNATOR','FontSize',16,'FontWeight','bold','color','blue')
      
      
      plot([1.3 3.7],[0 0],'-k','Linewidth',1)
      plot(q,fA,'-r','LineWidth',1.0)
      plot(q,fB,'-g','LineWidth',1.0)
      plot(q,fC,'-b','LineWidth',1.0)
      
      plot(s,fAo,'xr','MarkerSize',8,'LineWidth',1.8)
      plot(s,fBo,'og','MarkerSize',8,'LineWidth',1.8)
      plot(s,fCo,'+b','MarkerSize',8,'LineWidth',1.8)
     
     
      set(gca,'Xlim',[-1.0 4.0],'Ylim',[-1.0 1.0],'visible','off')
      axis equal
      hold off
      %          
      f=getframe(gca);
      avialt=addframe(avialt,f);
      phim=phim+dphi;
      e=e+360/n;
      s=1.3+k*2.4/n;
      M(k)=getframe;
  end
   avialt=close(avialt);
   uicontrol('Units','normalized', ...
   'Style','PushButton',...
	'BackgroundColor',[.2 .3 .8], ...
	'Callback','movie(M,1)', ...
	'FontSize',10, ...
	'FontWeight','bold', ...
	'ForegroundColor',[1 1 1], ...
	'Position',[0.24 0.15 0.09 .06], ...
	'String','Repeat', ...
    'TooltipString','Repeat');
    uicontrol('Units','normalized', ...
   'Style','PushButton',...
	'BackgroundColor',[.2 .3 .8], ...
	'Callback','close,clear,close all', ...
	'FontSize',10, ...
	'FontWeight','bold', ...
	'ForegroundColor',[1 1 1], ...
	'Position',[0.63 0.15 0.09 .06], ...
	'String','Quit', ...
    'TooltipString','Quit');
     
  %

⌨️ 快捷键说明

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