clear all; clc;

ps=0.002;
e=8.854*10^-12;
r=0:0.00001:0.1;
z=[-0.1,0.1,-0.2,0.2];

for n=1:length(z)
    E=sum(ps*z(n)*(r./(r.^2+z(n)^2).^(1.5)))/(2*e);
    if(z(n)>0)
        fprintf("The electric field along positive z direction at z=%f m is %e N/c \n",z(n),E);
    end
    if(z(n)<0)
        fprintf("The electric field along negative z direction at z= %f m is %e N/c \n ",z(n),E);
    end
end