% Animates the equipotential contours of an electric dipole % n = 2*pi; d = n/50+0.001; [x,y] = meshgrid(-n:d:n,-n:d:n); nn = 30 j=0; M = moviein(nn); for j=1:nn z=(x./sqrt(x.^2+y.^2)).^2.*(... -sin(sqrt(x.^2+y.^2)-j*2*pi/nn)... -cos(sqrt(x.^2+y.^2)-j*2*pi/nn)./sqrt(x.^2+y.^2)... ); v=[-1 -0.9 -0.8 -0.75 -0.5 -0.25 -0.1 -0.05 0 0.05 0.1 0.25 0.5 ... 0.75 0.8 0.9 1]; %v=[ -0.75 -0.5 -0.25 0 0.25 0.5 0.75 ]; contour(z,v); %contour(z,30); %colorbar axis equal %grid on M(:,j) = getframe; end movie(M,5,10)