SubhamRath

expt-4

Nov 11th, 2020 (edited)
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.43 KB | None | 0 0
  1. close all;
  2. clear all;
  3.  
  4. syms x y ep0
  5.  
  6. k=10^-9/(36*pi);
  7. E=[x^2 y^2];
  8.  
  9. rho=ep0*divergence(E,[x,y]);
  10. rho=subs(rho,ep0,k);
  11.  
  12. v=-2:0.1:2;
  13.  
  14. [xPlot,yPlot]=meshgrid(v);
  15. Ex=subs(E(1),x,xPlot);
  16. Ey=subs(E(2),y,yPlot);
  17. rhoPlot=double(subs(rho,{x,y},{xPlot,yPlot}));
  18. figure(1)
  19. quiver(xPlot,yPlot,Ex,Ey);
  20. hold on
  21. contour(xPlot,yPlot,rhoPlot)
  22. title('contour plot of charge density over electric field')
  23. xlabel('x');
  24. ylabel('y');
  25.  
Add Comment
Please, Sign In to add comment