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

📄 jfk2.asv

📁 电磁辐射的数值分析与仿真(基于MATLAB语言)。包括两个点电荷的电场
💻 ASV
📖 第 1 页 / 共 2 页
字号:
p1=get(handles.pop1,'Value');
p2=get(handles.pop2,'Value');
s1=get(handles.slider1,'value');

if p1==1
   q=2e-6;k=9e9;a=0.9;b=0;
   for n1=1:20
       t1=n1./20;
       axes(handles.axes1);
   x1=-t1:0.04:t1;y1=x1;
   [X1,Y1]=meshgrid(x1,y1);
   rp1=sqrt((X1-a).^2+(Y1-b).^2);rm1=sqrt((X1+a).^2+(Y1+b).^2);
   V1=q*k*(s1./rp1-1./rm1);
   [Ex1,Ey1]=gradient(-V1);
   AE1=sqrt(Ex1.^2+Ey1.^2);Ex1=Ex1./AE1;Ey1=Ey1./AE1;
   cv1=linspace(min(min(V1)),max(max(V1)),49);
  
        if p2==1
       contourf(X1,Y1,V1,cv1,'k-');axis([-t1 t1 -t1 t1]);
       axis('square');hold on;
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
   elseif p2==2
       quiver(X1,Y1,Ex1,Ey1,0.7);axis([-t1 t1 -t1 t1]);
       axis('square');
       hold on;
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
  elseif p2==3
       contourf(X1,Y1,V1,cv1,'k-');axis([-t1 t1 -t1 t1]);
       axis('square');
       hold on;
       quiver(X1,Y1,Ex1,Ey1,0.7);
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
 end
   m1(n1)=getframe;
end
movie(m1,2);
for n2=1:20
    t2=n2.*2.5;
     axes(handles.axes2);
   x2=-t2:20:t2;y2=x2;
   [X2,Y2]=meshgrid(x2,y2);
   rp2=sqrt((X2-a).^2+(Y2-b).^2);rm2=sqrt((X2+a).^2+(Y2+b).^2);
   V2=q*k*(1./rp2-1./rm2);
   [Ex2,Ey2]=gradient(-V2);
   AE2=sqrt(Ex2.^2+Ey2.^2);Ex2=Ex2./AE2;Ey2=Ey2./AE2;
   cv2=linspace(min(min(V2)),max(max(V2)),100);
  
   if p2==1
       contourf(X2,Y2,V2,cv2,'k-');axis([-t2 t2 -t2 t2]);
       axis('square');hold on;
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
   elseif p2==2
       quiver(X2,Y2,Ex2,Ey2,0.7);axis([-t2 t2 -t2 t2]);
       axis('square');
       hold on;
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
   elseif p2==3
       contourf(X2,Y2,V2,cv2,'k-');axis([-t2 t2 -t2 t2]);
       axis('square');
       hold on;
       quiver(X2,Y2,Ex2,Ey2,0.7);
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
   end
   m2=getframe;
end
movie(m2,2);

elseif p1==2

   q=2e-6;k=9e9;a=0.9;b=0;
   for n1=1:20
       t1=n1./20;
       axes(handles.axes1);
   x1=-t1:0.04:t1;y1=x1;
   [X1,Y1]=meshgrid(x1,y1);
   rp1=sqrt((X1-a).^2+(Y1-b).^2);rm1=sqrt((X1+a).^2+(Y1+b).^2);
   V1=q*k*(s1./rp1+1./rm1);
   [Ex1,Ey1]=gradient(-V1);
   AE1=sqrt(Ex1.^2+Ey1.^2);Ex1=Ex1./AE1;Ey1=Ey1./AE1;
   cv1=linspace(min(min(V1)),max(max(V1)),49);
  
        if p2==1
       contourf(X1,Y1,V1,cv1,'k-');axis([-t1 t1 -t1 t1]);
       axis('square');hold on;
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
   elseif p2==2
       quiver(X1,Y1,Ex1,Ey1,0.7);axis([-t1 t1 -t1 t1]);
       axis('square');
       hold on;
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
  elseif p2==3
       contourf(X1,Y1,V1,cv1,'k-');axis([-t1 t1 -t1 t1]);
       axis('square');
       hold on;
       quiver(X1,Y1,Ex1,Ey1,0.7);
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
 end
   m1(n1)=getframe;
end
movie(m1,2);
for n2=1:20
    t2=n2.*25;
     axes(handles.axes2);
   x2=-t2:20:t2;y2=x2;
   [X2,Y2]=meshgrid(x2,y2);
   rp2=sqrt((X2-a).^2+(Y2-b).^2);rm2=sqrt((X2+a).^2+(Y2+b).^2);
   V2=q*k*(1./rp2+1./rm2);
   [Ex2,Ey2]=gradient(-V2);
   AE2=sqrt(Ex2.^2+Ey2.^2);Ex2=Ex2./AE2;Ey2=Ey2./AE2;
   cv2=linspace(min(min(V2)),max(max(V2)),100);
  
   if p2==1
       contourf(X2,Y2,V2,cv2,'k-');axis([-t2 t2 -t2 t2]);
       axis('square');hold on;
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
   elseif p2==2
       quiver(X2,Y2,Ex2,Ey2,0.7);axis([-t2 t2 -t2 t2]);
       axis('square');
       hold on;
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
   elseif p2==3
       contourf(X2,Y2,V2,cv2,'k-');axis([-t2 t2 -t2 t2]);
       axis('square');
       hold on;
       quiver(X2,Y2,Ex2,Ey2,0.7);
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
   end
   m2=getframe;
end
movie(m2,2);
end
% --- Executes on button press in push3.function push3_Callback(hObject, eventdata, handles)% hObject    handle to push3 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)p1=get(handles.pop1,'Value');
p2=get(handles.pop2,'Value');

s2=get(handles.slider2,'Value');
s3=get(handles.slider3,'Value');

if p1==1
   
   q=2e-6;k=9e9;a=0.9;b=0;
   for k1=1:20
       axes(handles.axes1);
   x1=-s2:0.1:s2;y1=x1;
   [X1,Y1]=meshgrid(x1,y1);
   rp1=sqrt((X1-a).^2+(Y1-b).^2);rm1=sqrt((X1+a).^2+(Y1+b).^2);
   V1=q*k*(k1./rp1-1./rm1);
   [Ex1,Ey1]=gradient(-V1);
   AE1=sqrt(Ex1.^2+Ey1.^2);Ex1=Ex1./AE1;Ey1=Ey1./AE1;
   cv1=linspace(min(min(V1)),max(max(V1)),49);
   
   if p2==1
       contourf(X1,Y1,V1,cv1,'k-');axis([-s2 s2 -s2 s2]);
       axis('square');hold on;
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
   elseif p2==2
       quiver(X1,Y1,Ex1,Ey1,0.7);axis([-s2 s2 -s2 s2]);
       axis('square');
       hold on;
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
  elseif p2==3
       contourf(X1,Y1,V1,cv1,'k-');axis([-s2 s2 -s2 s2]);
       axis('square');
       hold on;
       quiver(X1,Y1,Ex1,Ey1,0.7);
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
 end
    m1(k1)=getframe;
end
movie(k1,2);

for k2=1:20
 axes(handles.axes2);
 x2=-s3:20:s3;y2=x2;
   [X2,Y2]=meshgrid(x2,y2);
   rp2=sqrt((X2-a).^2+(Y2-b).^2);rm2=sqrt((X2+a).^2+(Y2+b).^2);
   V2=q*k*(k1./rp2-1./rm2);
   [Ex2,Ey2]=gradient(-V2);
   AE2=sqrt(Ex2.^2+Ey2.^2);Ex2=Ex2./AE2;Ey2=Ey2./AE2;
   cv2=linspace(min(min(V2)),max(max(V2)),100);
  
   if p2==1
       contourf(X2,Y2,V2,cv2,'k-');axis([-s3 s3 -s3 s3]);
       axis('square');hold on;
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
   elseif p2==2
       quiver(X2,Y2,Ex2,Ey2,0.7);axis([-s3 s3 -s3 s3]);
       axis('square');
       hold on;
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
   elseif p2==3
       contourf(X2,Y2,V2,cv2,'k-');axis([-s3 s3 -s3 s3]);
       axis('square');
       hold on;
       quiver(X2,Y2,Ex2,Ey2,0.7);
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
   end
   m2(k2)=getframe;
end
movie(k2,2);
   
elseif p1==2
   q=2e-6;k=9e9;a=0.9;b=0;
   for k1=1:20
       axes(handles.axes1);
   x1=-s2:0.1:s2;y1=x1;
   [X1,Y1]=meshgrid(x1,y1);
   rp1=sqrt((X1-a).^2+(Y1-b).^2);rm1=sqrt((X1+a).^2+(Y1+b).^2);
   V1=q*k*(k1./rp1+1./rm1);
   [Ex1,Ey1]=gradient(-V1);
   AE1=sqrt(Ex1.^2+Ey1.^2);Ex1=Ex1./AE1;Ey1=Ey1./AE1;
   cv1=linspace(min(min(V1)),max(max(V1)),49);
   
   if p2==1
       contourf(X1,Y1,V1,cv1,'k-');axis([-s2 s2 -s2 s2]);
       axis('square');hold on;
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
   elseif p2==2
       quiver(X1,Y1,Ex1,Ey1,0.7);axis([-s2 s2 -s2 s2]);
       axis('square');
       hold on;
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
  elseif p2==3
       contourf(X1,Y1,V1,cv1,'k-');axis([-s2 s2 -s2 s2]);
       axis('square');
       hold on;
       quiver(X1,Y1,Ex1,Ey1,0.7);
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
 end
    m1(k1)=getframe;
end
movie(k1,2);

for k2=1:20
 axes(handles.axes2);
 x2=-s3:20:s3;y2=x2;
   [X2,Y2]=meshgrid(x2,y2);
   rp2=sqrt((X2-a).^2+(Y2-b).^2);rm2=sqrt((X2+a).^2+(Y2+b).^2);
   V2=q*k*(k1./rp2+1./rm2);
   [Ex2,Ey2]=gradient(-V2);
   AE2=sqrt(Ex2.^2+Ey2.^2);Ex2=Ex2./AE2;Ey2=Ey2./AE2;
   cv2=linspace(min(min(V2)),max(max(V2)),100);
  
   if p2==1
       contourf(X2,Y2,V2,cv2,'k-');axis([-s3 s3 -s3 s3]);
       axis('square');hold on;
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
   elseif p2==2
       quiver(X2,Y2,Ex2,Ey2,0.7);axis([-s3 s3 -s3 s3]);
       axis('square');
       hold on;
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
   elseif p2==3
       contourf(X2,Y2,V2,cv2,'k-');axis([-s3 s3 -s3 s3]);
       axis('square');
       hold on;
       quiver(X2,Y2,Ex2,Ey2,0.7);
       plot(a,b,'wo',a,b,'w-');
       plot(-a,-b,'wo',-a,-b,'w+');
       xlabel('x');ylabel('y');hold off;
   end
   m2(k2)=getframe;
end
movie(k2,2);
end
% --- Executes during object creation, after setting all properties.function pop2_CreateFcn(hObject, eventdata, handles)                                                                                                   % hObject    handle to pop2 (see GCBO)                                                                                                             % eventdata  reserved - to be defined in a future version of MATLAB                                                                                         % handles    empty - handles not created until after all CreateFcns called                                                                                                                                                                                                                                    % Hint: popupmenu controls usually have a white background on Windows.                                                                                          %       See ISPC and COMPUTER.                                                                                                                                                                       if ispc                                                                                                                                                     set(hObject,'BackgroundColor','white');                                                                                                                  else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));                                                                             end                                                                                                                                                                                                                                                                                                                 % --- Executes on selection change in pop2.                                                                                                                                                function pop2_Callback(hObject, eventdata, handles)                                                                                                        % hObject    handle to pop2 (see GCBO)                                                                                                                                                          % eventdata  reserved - to be defined in a future version of MATLAB                                                                                                   % handles    structure with handles and user data (see GUIDATA)                                                                                                        % Hints: contents = get(hObject,'String') returns pop2 contents as cell                                                                                         
%                                                                                                                                                                          
% array                                                                     
%                                                                                                                                                    %        contents{get(hObject,'Value')} returns selected item from pop2

⌨️ 快捷键说明

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