How to handle quiver3 vector scaling?

조회 수: 1 (최근 30일)
Jan Mar
Jan Mar 2019년 10월 27일
댓글: Jan Mar 2019년 10월 27일
How can I display the magnitude of the arrows for the line charge without resorting to unit vectors? I think I understand that quiver3 scales the vectors based on the highest number, however I am unsure how to deal with the high numbers in a mesh grid. I do have isinf = nan code, just incase.
Context: plotting electric fields due to line charge
range = -2:0.1:2;
[x,y,z] = meshgrid (range,range,range);
q1 = 2E-6; % Test Charge Value
k = 9E9; % Permitivity
circx = -1:.001:0;
extot = zeros(1,1,1);
eytot = zeros(1,1,1);
eztot = zeros(1,1,1);
% Test Charge 1 at (1,0,0)
% ex = (k*q1 ./ ((x-1).^2 + y.^2 + z.^2).^(3/2)) .* (x-1);
% ey = (k*q1 ./ ((x-1).^2 + (y).^2 + z.^2).^(3/2)) .* y;
% ez = (k*q1 ./ ((x-1).^2 + y.^2 + (z).^2).^(3/2)) .* z;
%% Line Charge
for num = 1:length(circx)
extot = extot + (k*q1 ./ ((x-circx(1,num)).^2 + y.^2 + ((z-abs(sqrt(1-circx(1,num).^2))).^2)).^(3/2)) .* (x-circx(1,num));
eytot = eytot + (k*q1 ./ ((x-circx(1,num)).^2 + y.^2 + ((z-abs(sqrt(1-circx(1,num).^2))).^2)).^(3/2)) .* (y);
eztot = eztot + (k*q1 ./ ((x-circx(1,num)).^2 + y.^2 + ((z-abs(sqrt(1-circx(1,num).^2))).^2)).^(3/2)) .* (z-(sqrt(1-circx(1,num).^2)));
end
quiver3(x,y,z,extot,eytot,eztot)
view(0,0)
Vectors plotted as is:
linechargeJPG.JPG
Dividing by the magnitude:
linechargmag.JPG
linechargemagn2.JPG
However I want the intensity to be similar to the behavior of the vectors for the point charges:
pointcharge.JPG
  댓글 수: 3
Daniel M
Daniel M 2019년 10월 27일
편집: Daniel M 2019년 10월 27일
I haven't looked into whether you've implemented the code properly (if you post the equation we can check that). Just wanted to point out that the electric field from a point charge falls off as 1/r^2, whereas a line charge falls off linearly. So, you shouldn't "want" the vector magnitudes to be scaled similarly to the point charges because that is not how physics says it will behave.
P.s. I love the image of the point charges. It is so cool. You should try to plot the field lines of a magnetic dipole next.
Jan Mar
Jan Mar 2019년 10월 27일
Sorry for the confusion! Yes, I want vectors to be more apparent near the line charge and fade the farther you move away.
In the for loop, if you change the iterations to 1:3, the vectors display the desired behavior. But anything beyond that the lines disappear.

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

답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by