Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- close all;
- clear all;
- syms x y ep0
- k=10^-9/(36*pi);
- E=[x^2 y^2];
- rho=ep0*divergence(E,[x,y]);
- rho=subs(rho,ep0,k);
- v=-2:0.1:2;
- [xPlot,yPlot]=meshgrid(v);
- Ex=subs(E(1),x,xPlot);
- Ey=subs(E(2),y,yPlot);
- rhoPlot=double(subs(rho,{x,y},{xPlot,yPlot}));
- figure(1)
- quiver(xPlot,yPlot,Ex,Ey);
- hold on
- contour(xPlot,yPlot,rhoPlot)
- title('contour plot of charge density over electric field')
- xlabel('x');
- ylabel('y');
Add Comment
Please, Sign In to add comment