Hi, check this question
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
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
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](https://www.mathworks.com/matlabcentral/answers/uploaded_files/261263/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!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!