Rowan-Classes/5th-Semester-Fall-2023/EEMAGS/Homework/H0306a.m
2024-02-22 14:23:12 -05:00

22 lines
324 B
Mathematica

clear all;
k = 9e9;
q1 = 1.0e-6;
q2 = -1.0e-6;
ax = 1.0;
ay = 0;
bx = -1.0;
by = 0;
[X, Y] = meshgrid(-2:0.9:2,-2:0.9:2);
V = 1./sqrt((X - ax).^2 + (Y-ay).^2 ) * k * q1 + 1./sqrt((X-bx).^2 + (Y-by).^2) * k * q2;
surfc(X, Y, V);
[Ex, Ey] = gradient(-V, 0.2, 0.2);
figure
contour(X, Y, V);
hold on;
quiver(X, Y, Ex, Ey);