Hi, check this question

1 次查看(过去 30 天)
Sai Hitesh Gorantla
Two 1 nC point positive charges are located at (-1, 0, 0) m and (1, 0, 0) m respectively. Write a MATLAB script to plot the magnitude of the electric field vector on the X axis between (-0.9, 0, 0) m and (0.9, 0, 0) m. Use the ‘plot’ command in MATLAB and use a spacing of 0.1 m between points along the X axis (Hint: x = -0.9:0.1:0.9). Ensure that you label the axes with appropriate units
  2 个评论
Walter Roberson
Walter Roberson 2020-1-11
I checked but I do not see any question there?
Steven Lord
Steven Lord 2020-1-11
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.

请先登录,再进行评论。

回答(1 个)

Meg Noah
Meg Noah 2020-1-11
Two Charges
% Two 1 nC point positive charges are located at (-1, 0, 0) m and (1, 0, 0) m respectively.
% Write a MATLAB script to plot the magnitude of the electric field vector
% on the X axis between (-0.9, 0, 0) m and (0.9, 0, 0) m.
% Use the ‘plot’ command in MATLAB and use a spacing of 0.1 m between
% points along the X axis (Hint: x = -0.9:0.1:0.9).
% Ensure that you label the axes with appropriate units
ke = 8.9875e9; % N·m2/C2 Coulomb's constant
% list of particle charge values
q = [1e-9;1e-9]; % [C]
% list of particle positions
p = [-1;1]; % [m]
x = -0.9:0.1:0.9; % [m]
E = zeros(size(x)); % [V/m]
% by superposition - add all the fields from all the charges
ncharges = length(q);
for icharge = 1:ncharges
R = x - p(icharge,:);
E = E + ke*q(icharge).*R./abs(R).^3;
end
figure();
plot(x,abs(E)); hold on;
plot(p(1),0,'*r');
plot(p(2),0,'*r');
box on; grid on;
ylabel('|E| [V/m]');
xlabel('X Position [m]');
twoCharges.png
A neutron walks into a bar, and asks the bartender how much it costs to get a beer. The bartender says for you, no charge!

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by