Advertisement
hiddenGem

Line Segment with a Current

Jun 25th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.99 KB | None | 0 0
  1. %% Line Segment with a Current
  2. % Determines the magnetic field of a line segment that bends at a point
  3.  
  4. % Constants
  5. muNaught = (4*pi)*10^-7 ;                %[T*m/A] Vacuum Permeability
  6.  
  7. % Inputs and Variables
  8. I = input('What is the current?\n');
  9. d = input('What is the distance from the point to the horizon line\n');
  10. opp = input('Vector component that is parallel to the horizon line\n');
  11.  
  12. % Outputs and Equations
  13. hyp = sqrt(opp^2+d^2);
  14. B = (1+opp/hyp)*muNaught*I/(4*pi*d);
  15. fprintf('The magnitude of the field is %.3e T', B)
  16.  
  17. %{
  18. If the point is not under the line segment then when the program asks for
  19.     the 'vector component that is parallel to the horizon', the user should
  20.     enter the negative value
  21. Assumes the line segment is in two parts. One part is long like the horzion
  22.      and the other part is bent off like ran into something.
  23. If you were to draw a vector coming out of the point that is directed at
  24.     the 'bent corner' of the line segment, the component that is parallel
  25.     to the horizon line will be the variable 'opp'. To check if your vector
  26.     is drawn correctly, the other component should be parallel to the
  27.     distance vector 'd'.
  28. %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement