Electric dipole/Code
From Knowino
%--Contour diagram of electric dipole potential field % Matlab (R) code. close all; clear all %--Prepare figure properties axis([-4 4 -5 5]); axis equal; xlabel('x-axis', 'Fonts', 15); ylabel('z-axis', 'Fonts', 15); set(gca, 'fonts', 14, 'Ytick', [-4:2: 4] ); hold on; %--Negative contours cont = zeros(9,1); cont(1) = 0.05; step = 0.02; for i=1:9 cont(i+1) = cont(i) + step; step = step*1.5; end cont = -100*cont; cont=round(cont); cont=cont/100; %--x grid x = [-3.5 : .05 : 3.5]; %--Negative z-grid z = [-5 : .05 : -.05]; %--Plot below x-axis [X Z] = meshgrid(x,z); P = Z./(sqrt(X.^2+Z.^2).^3); %<--- Function plotted [c h] = contour(X,Z,P, cont, 'b' ); clabel(c,h, 'manual', 'fonts', 12); %--Flip signs z = -z; cont = -cont; %--Plot above x-axis [X Z] = meshgrid(x,z); P = Z./(sqrt(X.^2+Z.^2).^3); %<--- Function plotted [c h] = contour(X,Z,P, cont, 'r'); clabel(c,h, 'manual', 'fonts', 12);