Using matlab Three particles of charge q1 2 times 106 C q2
Using matlab
Three particles of charge q_1 = - 2 times 10^-6 C, q_2 = 3 times 10^-6 C and q_3 = -1 times 10^-6 C are located on the x-axis at the point x_1 = 0, x_2 = 10^-2 m and x_3 = 2 times 10^-2 m, respectively. Therefore the absolute electric potential at any point in x-y plane is calculated by the following equation: V = sigma_i = 1^3 k q_i/Squareroot (x - xi)^2 + (y - yi)^2 a) Write a code to calculate V. Please use a grid of 100 100 points to cover the area of - 0.005 lessthanorequalto x lessthanorequalto 0.025 and - 0.004 lessthanorequalto y lessthanorequalto 0.004. Then use fur to plot V in this area, and finally use a command to make this plot smoother. (The figure might look like the graph below). Solution
q1 = -2 * 10^-6;
q2 = 3 * 10^6;
q3 = -1 * 10^-6;
x1 = 0;
x2 = 10^-2;
x3 = 2 * 10^-2;
k = 8.99 * 10^9;
V = [];
x = linspace(-0.005, 0.025, 100);
y = linspace(-0.004, 0.004, 100);
for i = 1:100
for j = 1:100
temp1 = k * q1 / sqrt((x(i) - x1)^2 + (y(j) - 0)^2);
temp2 = k * q2 / sqrt((x(i) - x2)^2 + (y(j) - 0)^2);
temp3 = k * q3 / sqrt((x(i) - x3)^2 + (y(j) - 0)^2);
V(i, j) = temp1 + temp2 + temp3;
end
end
surf(x, y, V)
