필터 지우기
필터 지우기

HELP:) Electric Field lines on MatLab (solving fields given coordinate points)

조회 수: 14 (최근 30일)
Matlab
Matlab 2016년 5월 13일
댓글: Rena Berman 2020년 5월 14일
Currently I have used and edited a code that I have found on creating electric field lines on MatLab, I have use two test points at set coordinates with set charges [1 -1], yet the field lines that I get on my solution is incorrect. The direction of the lines should be all away from positive and towards the negative charges. Please help me fix this code!
x=[3 8];
y=[5 5];
q=[-1 1];
% Coulumb's number
ke = 8.9875517873681764e9;
xi=linspace(0,10,33);
yi=linspace(0,10,33);
[XI YI] = meshgrid(xi,yi);
zi = complex(XI,YI);
z = complex(x,y);
[ZI Z]=ndgrid(zi(:),z(:));
dZ = ZI-Z;
Zn = abs(dZ);
E = (dZ./Zn.^3)*(q(:)*ke);
E = reshape(E,size(XI));
En = abs(E);
Ex = real(E);
Ey = imag(E);
figure;
quiver(XI,YI,Ex./E,Ey./E);
hold on;
plot(x,y,'or');
axis equal;
Thank you,
  댓글 수: 3
Rik
Rik 2020년 4월 23일
Why did you remove your question content? Now it has become utterly useles. Even old questions can be very useful if they happen to solve the exact problem you're having.

댓글을 달려면 로그인하십시오.

답변 (2개)

Matt
Matt 2016년 5월 13일
In your line quiver(XI,YI,Ex./E,Ey./E); change E to En.
You are currently dividing by a complex number.

Antonio Cedillo Hernandez
Antonio Cedillo Hernandez 2020년 4월 21일
Here you have the full MATLAB code explained (in spanish but the first comment is the code): https://www.youtube.com/watch?v=k9srU6aQfL0

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by