%EEMAG1 Fall 00
%S. Mandayam, ECE, Rowan University
%Fields due to discrete and line charge distributions

close all; clear;
[x,y,z] = meshgrid(-1:0.05:1,0.001:0.05:1,-1:0.05:1);
%Point Charge
E = 1./(x.^2+y.^2+z.^2);
figure(1);
slice(x,y,z,log(E),[-0.9:0.05:0.9],0.9,[-0.9:0.05:0.9]);shading interp;
colormap hsv;
xlabel('x');
ylabel('y');
zlabel('z');
title('Electric Field (Log Magnitude)due to point charge at origin (0,0,0)');
axis square;
colorbar;
rotate3d on;
pause;

%Line Charge
E = 1./sqrt(x.^2+y.^2);
figure(2);
slice(x,y,z,log(E),[-0.9:0.1:0.9],0.9,[-0.9:0.1:0.9]);shading interp;
colormap hsv;
xlabel('x');
ylabel('y');
zlabel('z');
title('Electric Field (Log Magnitude)due to line charge along z-axis');
axis square;
colorbar;
rotate3d on;
