Advertisement
SubhamRath

contour plot of charge density over electric field

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