Question

2- Write a MATLAB code to visualize (2D) the electric field vector due to four equal point charges Q, Placed at vertices of a

0 0
Add a comment Improve this question Transcribed image text
Answer #1

%we can use this code to generate the vector plot

clear all;

clc;

close all;

%Single input : define the number of points

lamda = input('Enter the charge Density in Q/m:(example "5e-9" , which is 5nC)');

%

l = input('Enter the edge length of visulatiztion box centerd at wire,in meters (example "1" which is 1 meter:)'); %created a 2D mesh resolution = 0.1 ;% default of 0.1meters [x,y] = meshgrid(-1*l/2:resolution:l/2,-1*l/2:resolution:l/2) ;

eps0 = 8.854*1e-12;

%no create a 2D array with field flux values

% magnitude of electric field due to infinite line = lamda/(2*pi*r*eps0) ;

r = sqrt(x.^2+y.^2);

theta = ((atan(y./x)).(x>=0)) + ((pi+atan(y./x)).(x<0));

E = lamda./(2*pi.*r.*eps0) ;

%compute components Ex = E.*cos(theta); Ey = E.*sin(theta);

%plot the 2D flux of filed lines contour(x,y,E);

hold on;

quiver(x,y,Ex,Ey);

hold off;

grid on;

xlabel('x') ylabel('y') title('Electric field line vector plot ')

%*****

%sample run :

Enter the charge Density in Q/m:(example "5e-9" , which is 5nC)5e-9

Enter the edge length of visulatiztion box centerd at wire,in meters (example "1" which is 1 meter:)1

Electric field ine wector plot

Add a comment
Know the answer?
Add Answer to:
2- Write a MATLAB code to visualize (2D) the electric field vector due to four equal point charge...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT