% Plots the electric field vectors and equipotential contours % to show the solution to a quasistatics problem. % % Colin Joye % 6.641 (MIT) % Problem Set: #6 % Problem: P6.2c clear all; clf(1); [x,y] = meshgrid(-3:0.1:3,-6:0.2:6); z = cos(y).*exp(-abs(x)); % Electric Field [px,py] = gradient(z); % Equipotential lines [c,h]=contour(x,y,z); hold on clabel(c); colorbar; x_=x(1:2:end,1:2:end); y_=y(1:2:end,1:2:end); px_=px(1:2:end,1:2:end); py_=py(1:2:end,1:2:end); plot([-3,3],[0,0],'k'); quiver(x_,y_,-px_,-py_); hold off; title(['Equipotential and Electric Field lines ' ... '(arbitrary scaling a=1), P6.2, Colin Joye']); xlabel(['x']); ylabel(['y']); text(-2.8,1.7,['cos(ay)e^-^a^*^a^b^s^(^x^)=const']); %----